-
Notifications
You must be signed in to change notification settings - Fork 7
/
options_test.go
70 lines (62 loc) · 1.58 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
64
65
66
67
68
69
70
package mjml
import (
"reflect"
"testing"
)
func TestOptions(t *testing.T) {
beautifyOptions := NewBeautifyOptions().IndentEmptyLines(true).WrapLineLength(10)
juiceOptions := NewJuiceOptions().PreserveKeyFrames(true).PreservePseudos(true)
htmlMinifierOptions := NewHTMLMinifierOptions().HTML5(true).MinifyURLs(true)
o := options{data: map[string]interface{}{}}
optionFunctions := []ToHTMLOption{
WithBeautify(true),
WithBeautifyOptions(beautifyOptions),
WithFonts(Fonts{"test": "test"}),
WithJuiceOptions(juiceOptions),
WithJuicePreserveTags(
map[string]JuiceTag{
"myTag": {
Start: "<#",
End: "</#",
},
},
),
WithKeepComments(true),
WithMinify(true),
WithMinifyOptions(htmlMinifierOptions),
WithPreprocessors([]string{"(xml) => xml"}),
WithValidationLevel(Strict),
}
for _, f := range optionFunctions {
f(o)
}
expected := map[string]interface{}{
"beautify": true,
"beautifyOptions": map[string]interface{}{
"indent_empty_lines": true,
"wrap_line_length": uint(10),
},
"fonts": Fonts{"test": "test"},
"juiceOptions": map[string]interface{}{
"preserveKeyFrames": true,
"preservePseudos": true,
},
"juicePreserveTags": map[string]JuiceTag{
"myTag": {
Start: "<#",
End: "</#",
},
},
"keepComments": true,
"minify": true,
"minifyOptions": map[string]interface{}{
"html5": true,
"minifyURLs": true,
},
"preprocessors": []string{"(xml) => xml"},
"validationLevel": Strict,
}
if !reflect.DeepEqual(o.data, expected) {
t.Error("Options does not match expected data")
}
}