]> git.giacomolli.uk - onechat/blobdiff - telegram_markdown_test.go
Name and order the Telegram bot code
[onechat] / telegram_markdown_test.go
similarity index 89%
rename from markdown_test.go
rename to telegram_markdown_test.go
index cca7db00fa44a9208a4fce8eaee68f7b3bd94467..e2a253056e251b8877c6972c229d7b808f85061e 100644 (file)
@@ -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)
                })