MCPcopy Index your code
hub / github.com/dnote/dnote / TestFormatBody

Function TestFormatBody

pkg/cli/cmd/view/book_test.go:68–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

66}
67
68func TestFormatBody(t *testing.T) {
69 testCases := []struct {
70 input string
71 expectedBody string
72 expectedExcerpt bool
73 }{
74 {
75 input: "single line",
76 expectedBody: "single line",
77 expectedExcerpt: false,
78 },
79 {
80 input: "first line\nsecond line",
81 expectedBody: "first line",
82 expectedExcerpt: true,
83 },
84 {
85 input: "first line\r\nsecond line",
86 expectedBody: "first line",
87 expectedExcerpt: true,
88 },
89 {
90 input: " spaced line ",
91 expectedBody: "spaced line",
92 expectedExcerpt: false,
93 },
94 {
95 input: " first line \nsecond line",
96 expectedBody: "first line",
97 expectedExcerpt: true,
98 },
99 {
100 input: "",
101 expectedBody: "",
102 expectedExcerpt: false,
103 },
104 {
105 input: "line with trailing newline\n",
106 expectedBody: "line with trailing newline",
107 expectedExcerpt: false,
108 },
109 {
110 input: "line with trailing newlines\n\n",
111 expectedBody: "line with trailing newlines",
112 expectedExcerpt: false,
113 },
114 }
115
116 for _, tc := range testCases {
117 t.Run(fmt.Sprintf("input: %q", tc.input), func(t *testing.T) {
118 gotBody, gotExcerpt := formatBody(tc.input)
119 assert.Equal(t, gotBody, tc.expectedBody, "formatted body mismatch")
120 assert.Equal(t, gotExcerpt, tc.expectedExcerpt, "excerpt flag mismatch")
121 })
122 }
123}
124
125func TestListNotes(t *testing.T) {

Callers

nothing calls this directly

Calls 2

EqualFunction · 0.92
formatBodyFunction · 0.85

Tested by

no test coverage detected