forked from Swiggy/protoc-gen-doc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
filters_test.go
51 lines (43 loc) · 1.76 KB
/
filters_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package gendoc_test
import (
html "html/template"
"testing"
. "github.com/pseudomuto/protoc-gen-doc"
"github.com/stretchr/testify/require"
)
func TestPFilter(t *testing.T) {
tests := map[string]string{
"Some content.": "<p>Some content.</p>",
"Some content.\nRight here.": "<p>Some content.</p><p>Right here.</p>",
"Some content.\r\nRight here.": "<p>Some content.</p><p>Right here.</p>",
"Some content.\n\tRight here.": "<p>Some content.</p><p>Right here.</p>",
"Some content.\r\n\n \r\n Right here.": "<p>Some content.</p><p>Right here.</p>",
}
for input, output := range tests {
require.Equal(t, html.HTML(output), PFilter(input))
}
}
func TestParaFilter(t *testing.T) {
tests := map[string]string{
"Some content.": "<para>Some content.</para>",
"Some content.\nRight here.": "<para>Some content.</para><para>Right here.</para>",
"Some content.\r\nRight here.": "<para>Some content.</para><para>Right here.</para>",
"Some content.\n\tRight here.": "<para>Some content.</para><para>Right here.</para>",
"Some content.\r\n\n \r\n Right here.": "<para>Some content.</para><para>Right here.</para>",
}
for input, output := range tests {
require.Equal(t, output, ParaFilter(input))
}
}
func TestNoBrFilter(t *testing.T) {
tests := map[string]string{
"My content": "My content",
"My content \r\nHere.": "My content Here.",
"My\n content\r right\r\n here.": "My content right here.",
"My\ncontent\rright\r\nhere.": "My content right here.",
"My content.\n\nMore content.": "My content.\n\nMore content.",
}
for input, output := range tests {
require.Equal(t, output, NoBrFilter(input))
}
}