X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/fb242538c1b012b0faf3cc4045a9b1c370f1ef42:/markdown_test.go..09cde69fdffe2721434392036f98dc241177f5a1:/telegram_markdown_test.go diff --git a/markdown_test.go b/telegram_markdown_test.go similarity index 89% rename from markdown_test.go rename to telegram_markdown_test.go index cca7db0..e2a2530 100644 --- a/markdown_test.go +++ b/telegram_markdown_test.go @@ -11,13 +11,13 @@ func TestMarkdownEntities(t *testing.T) { name string markdown string text string - entities []botEntity + entities []TelegramEntity }{ { name: "double asterisks give bold", markdown: "a **b** c", text: "a b c", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "bold", Offset: 2, @@ -29,7 +29,7 @@ func TestMarkdownEntities(t *testing.T) { name: "double underscores give bold", markdown: "__bold__", text: "bold", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "bold", Offset: 0, @@ -41,7 +41,7 @@ func TestMarkdownEntities(t *testing.T) { name: "single asterisk gives italic", markdown: "an *odd* word", text: "an odd word", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "italic", Offset: 3, @@ -53,7 +53,7 @@ func TestMarkdownEntities(t *testing.T) { name: "single underscore gives italic", markdown: "an _odd_ word", text: "an odd word", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "italic", Offset: 3, @@ -65,7 +65,7 @@ func TestMarkdownEntities(t *testing.T) { name: "double tildes give strikethrough", markdown: "~~old~~ new", text: "old new", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "strikethrough", Offset: 0, @@ -77,7 +77,7 @@ func TestMarkdownEntities(t *testing.T) { name: "backticks give inline code with no entity inside", markdown: "run `go **test**` now", text: "run go **test** now", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "code", Offset: 4, @@ -89,7 +89,7 @@ func TestMarkdownEntities(t *testing.T) { name: "double backticks hold a backtick", markdown: "``a ` b``", text: "a ` b", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "code", Offset: 0, @@ -101,7 +101,7 @@ func TestMarkdownEntities(t *testing.T) { name: "link gives a text link", markdown: "see [the docs](https://example.com/a_b) here", text: "see the docs here", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "text_link", Offset: 4, @@ -114,7 +114,7 @@ func TestMarkdownEntities(t *testing.T) { name: "bold inside a link nests", markdown: "[a **b** c](https://example.com)", text: "a b c", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "text_link", Offset: 0, @@ -132,7 +132,7 @@ func TestMarkdownEntities(t *testing.T) { name: "code block with a language gives pre with the language", markdown: "Commit:\n```text\nFix the **bug**\n\nBody\n```\nDone.", text: "Commit:\nFix the **bug**\n\nBody\nDone.", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "pre", Offset: 8, @@ -145,7 +145,7 @@ func TestMarkdownEntities(t *testing.T) { name: "code block without a language gives pre", markdown: "```\nls -l\n```", text: "ls -l", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "pre", Offset: 0, @@ -157,7 +157,7 @@ func TestMarkdownEntities(t *testing.T) { name: "heading becomes bold with its inline marks", markdown: "## The `plan`\nnext", text: "The plan\nnext", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "bold", Offset: 0, @@ -179,7 +179,7 @@ func TestMarkdownEntities(t *testing.T) { name: "asterisk of a list item with italic later stays", markdown: "* item with *stress*", text: "* item with stress", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "italic", Offset: 12, @@ -221,7 +221,7 @@ func TestMarkdownEntities(t *testing.T) { name: "character outside the BMP moves the offset by two", markdown: "\U0001F600 **b**", text: "\U0001F600 b", - entities: []botEntity{ + entities: []TelegramEntity{ { Type: "bold", Offset: 3, @@ -233,7 +233,7 @@ func TestMarkdownEntities(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - text, entities := markdownEntities(tc.markdown) + text, entities := telegramMarkdownEntities(tc.markdown) require.Equal(t, tc.text, text) require.Equal(t, tc.entities, entities) })