-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhtml_minifier_options_test.go
96 lines (89 loc) · 3.21 KB
/
html_minifier_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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package mjml
import (
"reflect"
"testing"
)
func TestHTMLMiniferOptions(t *testing.T) {
options := NewHTMLMinifierOptions().
CaseSensitive(true).
CollapseBooleanAttributes(true).
CollapseInlineTagWhitespace(true).
CollapseWhitespace(true).
ConservativeCollapse(true).
ContinueOnParseError(true).
CustomAttrAssign([]string{"<div flex?=\"{{mode != cover}}\"></div>"}).
CustomAttrCollapse("ng-class").
CustomAttrSurround([]string{"<input {{#if value}}checked=\"checked\"{{/if}}>"}).
DecodeEntities(true).
HTML5(true).
IgnoreCustomComments([]string{"^!"}).
IgnoreCustomFragments([]string{"<%[\\s\\S]*?%>"}).
IncludeAutoGeneratedTags(true).
KeepClosingSlash(true).
MaxLineLength(50).
MinifyCSS(true).
MinifyURLs(true).
PreserveLineBreaks(true).
PreventAttributesEscaping(true).
ProcessConditionalComments(true).
ProcessScripts([]string{"text/ng-template"}).
QuoteCharacter(HTMLMinifierDoubleQuote).
RemoveAttributeQuotes(true).
RemoveComments(true).
RemoveEmptyAttributes(true).
RemoveEmptyElements(true).
RemoveOptionalTags(true).
RemoveRedundantAttributes(true).
RemoveScriptTypeAttributes(true).
RemoveStyleLinkTypeAttributes(true).
RemoveTagWhitespace(true).
SortAttributes(true).
SortClassName(true).
TrimCustomFragments(true).
UseShortDoctype(true)
expected := map[string]interface{}{
"caseSensitive": true,
"collapseBooleanAttributes": true,
"collapseInlineTagWhitespace": true,
"collapseWhitespace": true,
"conservativeCollapse": true,
"continueOnParseError": true,
"customAttrAssign": []string{"<div flex?=\"{{mode != cover}}\"></div>"},
"customAttrCollapse": "ng-class",
"customAttrSurround": []string{"<input {{#if value}}checked=\"checked\"{{/if}}>"},
"decodeEntities": true,
"html5": true,
"ignoreCustomComments": []string{"^!"},
"ignoreCustomFragments": []string{"<%[\\s\\S]*?%>"},
"includeAutoGeneratedTags": true,
"keepClosingSlash": true,
"maxLineLength": uint(50),
"minifyCSS": true,
"minifyURLs": true,
"preserveLineBreaks": true,
"preventAttributesEscaping": true,
"processConditionalComments": true,
"processScripts": []string{"text/ng-template"},
"quoteCharacter": HTMLMinifierDoubleQuote,
"removeAttributeQuotes": true,
"removeComments": true,
"removeEmptyAttributes": true,
"removeEmptyElements": true,
"removeOptionalTags": true,
"removeRedundantAttributes": true,
"removeScriptTypeAttributes": true,
"removeStyleLinkTypeAttributes": true,
"removeTagWhitespace": true,
"sortAttributes": true,
"sortClassName": true,
"trimCustomFragments": true,
"useShortDoctype": true,
}
htmlMinifierOptions, ok := options.(*htmlMinifierOptions)
if !ok {
t.Fatal("Options is not a *htmlMinifierOptions")
}
if !reflect.DeepEqual(htmlMinifierOptions.data, expected) {
t.Error("HTMLMinifierOptions does not match expected data")
}
}