forked from pseudomuto/protoc-gen-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filters_test.go
78 lines (66 loc) · 2.57 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package gendoc_test
import (
html "html/template"
"testing"
. "github.com/beatlabs/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))
}
}
func TestBrMdFilter(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.<br><br>More content.",
}
for input, output := range tests {
require.Equal(t, html.HTML(output), BrFilterMD(input))
}
}
func TestAnchorFilter(t *testing.T) {
tests := map[string]string{
"com/example/test.proto": "com_example_test-proto",
"com.example.SomeRequest": "com-example-SomeRequest",
"héllô": "h-ll-",
"un_modified-Content": "un_modified-Content",
}
for input, output := range tests {
require.Equal(t, output, AnchorFilter(input))
}
}