-
Notifications
You must be signed in to change notification settings - Fork 5
/
options_test.go
63 lines (57 loc) · 1.46 KB
/
options_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
package markdown
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/yuin/goldmark/renderer"
)
// TestRendererOptions tests the methods for setting configuration options on the renderer
func TestRendererOptions(t *testing.T) {
var cases = []struct {
name string
options []Option
expected *Config
}{
{
"Defaults",
[]Option{},
NewConfig(),
},
{
"Explicit defaults",
[]Option{
WithIndentStyle(IndentStyleSpaces),
WithHeadingStyle(HeadingStyleATX),
WithThematicBreakStyle(ThematicBreakStyleDashed),
WithThematicBreakLength(ThematicBreakLengthMinimum),
},
NewConfig(),
},
{
"Tab indent",
[]Option{WithIndentStyle(IndentStyleTabs)},
NewConfig(WithIndentStyle(IndentStyleTabs)),
},
{
"Underlined thematic breaks",
[]Option{WithThematicBreakStyle(ThematicBreakStyleUnderlined)},
NewConfig(WithThematicBreakStyle(ThematicBreakStyleUnderlined)),
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
assert := assert.New(t)
// Set options by passing them directly to NewRenderer
r := NewRenderer(tc.options...)
assert.Equal(tc.expected, r.config)
// Set options by name using AddOptions
r = NewRenderer()
// Convert markdown Option interface to renderer.Option interface
options := make([]renderer.Option, len(tc.options))
for i, o := range tc.options {
options[i] = o
}
r.AddOptions(options...)
assert.Equal(tc.expected, r.config)
})
}
}