MCPcopy Index your code
hub / github.com/writefreely/writefreely / TestPostSummary

Function TestPostSummary

posts_test.go:21–41  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestPostSummary(t *testing.T) {
22 testCases := map[string]struct {
23 given writefreely.Post
24 expected string
25 }{
26 "no special chars": {givenPost("Content."), "Content."},
27 "HTML content": {givenPost("Content <p>with a</p> paragraph."), "Content with a paragraph."},
28 "content with escaped char": {givenPost("Content&#39;s all OK."), "Content's all OK."},
29 "multiline content": {givenPost(`Content
30in
31multiple
32lines.`), "Content in multiple lines."},
33 }
34
35 for name, test := range testCases {
36 t.Run(name, func(t *testing.T) {
37 actual := test.given.Summary()
38 assert.Equal(t, test.expected, actual)
39 })
40 }
41}
42
43func givenPost(content string) writefreely.Post {
44 return writefreely.Post{Title: zero.StringFrom("Title"), Content: content}

Callers

nothing calls this directly

Calls 2

givenPostFunction · 0.85
SummaryMethod · 0.80

Tested by

no test coverage detected