Skip to content

Commit

Permalink
tests: add markdown v2 test case
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Oct 1, 2022
1 parent c4f759f commit 5117f06
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,20 @@ func TestBot(t *testing.T) {
assert.Equal(t, "new caption with html", edited.Caption)
assert.Equal(t, EntityBold, edited.CaptionEntities[0].Type)

sleep()

edited, err = b.EditCaption(msg, "*new caption with markdown*", ModeMarkdown)
require.NoError(t, err)
assert.Equal(t, "new caption with markdown", edited.Caption)
assert.Equal(t, EntityBold, edited.CaptionEntities[0].Type)

sleep()

edited, err = b.EditCaption(msg, "_new caption with markdown \\(V2\\)_", ModeMarkdownV2)
require.NoError(t, err)
assert.Equal(t, "new caption with markdown (V2)", edited.Caption)
assert.Equal(t, EntityItalic, edited.CaptionEntities[0].Type)

b.parseMode = ModeDefault
})

Expand Down Expand Up @@ -602,29 +611,37 @@ func TestBot(t *testing.T) {
require.NoError(t, b.DeleteCommands())
})

t.Run("CreateInviteLink", func(t *testing.T) {
t.Run("InviteLink", func(t *testing.T) {
inviteLink, err := b.CreateInviteLink(&Chat{ID: chatID}, nil)
assert.Nil(t, err)
require.NoError(t, err)
assert.True(t, len(inviteLink.InviteLink) > 0)
})

t.Run("EditInviteLink", func(t *testing.T) {
inviteLink, err := b.CreateInviteLink(&Chat{ID: chatID}, nil)
assert.Nil(t, err)
sleep()

inviteLink, err = b.CreateInviteLink(&Chat{ID: chatID}, nil)
require.NoError(t, err)
assert.True(t, len(inviteLink.InviteLink) > 0)

sleep()

response, err := b.EditInviteLink(&Chat{ID: chatID}, &ChatInviteLink{InviteLink: inviteLink.InviteLink})
assert.Nil(t, err)
require.NoError(t, err)
assert.True(t, len(response.InviteLink) > 0)
})

t.Run("RevokeInviteLink", func(t *testing.T) {
inviteLink, err := b.CreateInviteLink(&Chat{ID: chatID}, nil)
assert.Nil(t, err)
sleep()

inviteLink, err = b.CreateInviteLink(&Chat{ID: chatID}, nil)
require.Nil(t, err)
assert.True(t, len(inviteLink.InviteLink) > 0)

response, err := b.RevokeInviteLink(&Chat{ID: chatID}, inviteLink.InviteLink)
assert.Nil(t, err)
sleep()

response, err = b.RevokeInviteLink(&Chat{ID: chatID}, inviteLink.InviteLink)
require.Nil(t, err)
assert.True(t, len(response.InviteLink) > 0)
})
}

func sleep() {
time.Sleep(time.Second)
}

0 comments on commit 5117f06

Please sign in to comment.