mirror of
https://github.com/axllent/mailpit.git
synced 2025-03-19 21:28:07 +02:00
Tests: Add snippet tests
This commit is contained in:
parent
636918dd0e
commit
52405915fa
@ -108,10 +108,9 @@ Content-Transfer-Encoding: 7bit
|
|||||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
Message with inline image and attachment:<br>
|
<h1>Message with inline image and attachment:</h1>
|
||||||
<br>
|
<br>
|
||||||
<img src="cid:part1.845LaYlX.wtWMpWwa@gmail.com"
|
<p><img src="cid:part1.845LaYlX.wtWMpWwa@gmail.com"></p>
|
||||||
moz-do-not-send="false"><br>
|
|
||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
</body>
|
</body>
|
||||||
|
@ -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["<h1>This is a test.</h1> "] = "This is a test."
|
||||||
|
tests["this_is-a test "] = "this_is-a test"
|
||||||
|
tests["this_is-a&^%%(*)@ test"] = "this_is-a&^%%(*)@ test"
|
||||||
|
tests["<h1>Heading</h1><p>Paragraph</p>"] = "Heading Paragraph"
|
||||||
|
tests[`<h1>Heading</h1>
|
||||||
|
<p>Paragraph</p>`] = "Heading Paragraph"
|
||||||
|
tests[`<h1>Heading</h1><p> <a href="https://github.com">linked text</a></p>`] = "Heading linked text"
|
||||||
|
// broken html
|
||||||
|
tests[`<h1>Heading</h3><p> <a href="https://github.com">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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user