diff --git a/internal/storage/testdata/mime-attachment.eml b/internal/storage/testdata/mime-attachment.eml index add00c7..f998414 100644 --- a/internal/storage/testdata/mime-attachment.eml +++ b/internal/storage/testdata/mime-attachment.eml @@ -108,10 +108,9 @@ Content-Transfer-Encoding: 7bit - Message with inline image and attachment:
+

Message with inline image and attachment:


-
+



diff --git a/internal/tools/tools_test.go b/internal/tools/tools_test.go index edfb947..ad2321d 100644 --- a/internal/tools/tools_test.go +++ b/internal/tools/tools_test.go @@ -43,3 +43,29 @@ func TestCleanTag(t *testing.T) { } } } + +func TestSnippets(t *testing.T) { + tests := map[string]string{} + tests["this is a test"] = "this is a test" + tests["thiS IS a Test"] = "thiS IS a Test" + tests["thiS IS a Test :-)"] = "thiS IS a Test :-)" + tests["

This is a test.

"] = "This is a test." + tests["this_is-a test "] = "this_is-a test" + tests["this_is-a&^%%(*)@ test"] = "this_is-a&^%%(*)@ test" + tests["

Heading

Paragraph

"] = "Heading Paragraph" + tests[`

Heading

+

Paragraph

`] = "Heading Paragraph" + tests[`

Heading

linked text

`] = "Heading linked text" + // broken html + tests[`

Heading

linked text.`] = "Heading linked text." + // truncation to 200 chars + ... + tests["abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789"] = "abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmnopqrstuvwxyx0123456789 abcdefghijklmno..." + + for str, expected := range tests { + res := CreateSnippet(str, str) + if res != expected { + t.Log("CreateSnippet error:", res, "!=", expected) + t.Fail() + } + } +}