@@ -42,62 +42,87 @@ func TestConfig(t *testing.T) {
4242 c .Assert (conf .Tdewolff .HTML .KeepWhitespace , qt .Equals , false )
4343 // default value
4444 c .Assert (conf .Tdewolff .HTML .KeepEndTags , qt .Equals , true )
45- c .Assert (conf .Tdewolff .CSS .KeepCSS2 , qt .Equals , true )
45+ c .Assert (conf .Tdewolff .CSS .Version , qt .Equals , 0 )
4646
4747 // `enable` flags
4848 c .Assert (conf .DisableHTML , qt .Equals , false )
4949 c .Assert (conf .DisableXML , qt .Equals , true )
5050}
5151
52- func TestConfigLegacy (t * testing.T ) {
52+ func TestConfigDeprecations (t * testing.T ) {
5353 c := qt .New (t )
54+
55+ // Test default values of deprecated root keys.
5456 v := config .New ()
57+ v .Set ("minify" , false )
58+ conf := testconfig .GetTestConfigs (nil , v ).Base .Minify
59+ c .Assert (conf .MinifyOutput , qt .Equals , false )
5560
56- // This was a bool < Hugo v0.58.
61+ v = config .New ()
62+ v .Set ("minifyoutput" , false )
63+ conf = testconfig .GetTestConfigs (nil , v ).Base .Minify
64+ c .Assert (conf .MinifyOutput , qt .Equals , false )
65+
66+ // Test non-default values of deprecated root keys.
67+ v = config .New ()
5768 v .Set ("minify" , true )
69+ conf = testconfig .GetTestConfigs (nil , v ).Base .Minify
70+ c .Assert (conf .MinifyOutput , qt .Equals , true )
5871
59- conf := testconfig .GetTestConfigs (nil , v ).Base .Minify
72+ v = config .New ()
73+ v .Set ("minifyoutput" , true )
74+ conf = testconfig .GetTestConfigs (nil , v ).Base .Minify
6075 c .Assert (conf .MinifyOutput , qt .Equals , true )
6176}
6277
63- func TestConfigNewCommentOptions (t * testing.T ) {
78+ func TestConfigUpstreamDeprecations (t * testing.T ) {
6479 c := qt .New (t )
65- v := config .New ()
6680
67- // setting the old options should automatically set the new options
81+ // Test default values of deprecated keys.
82+ v := config .New ()
6883 v .Set ("minify" , map [string ]any {
6984 "tdewolff" : map [string ]any {
85+ "css" : map [string ]any {
86+ "decimals" : 0 ,
87+ "keepcss2" : true ,
88+ },
7089 "html" : map [string ]any {
71- "keepConditionalComments " : false ,
90+ "keepconditionalcomments " : true ,
7291 },
7392 "svg" : map [string ]any {
74- "decimal " : "5" ,
93+ "decimals " : 0 ,
7594 },
7695 },
7796 })
7897
7998 conf := testconfig .GetTestConfigs (nil , v ).Base .Minify
8099
81- c .Assert (conf .Tdewolff .HTML .KeepSpecialComments , qt .Equals , false )
82- c .Assert (conf .Tdewolff .SVG .Precision , qt .Equals , 5 )
100+ c .Assert (conf .Tdewolff .CSS .Precision , qt .Equals , 0 )
101+ c .Assert (conf .Tdewolff .CSS .Version , qt .Equals , 2 )
102+ c .Assert (conf .Tdewolff .HTML .KeepSpecialComments , qt .Equals , true )
103+ c .Assert (conf .Tdewolff .SVG .Precision , qt .Equals , 0 )
83104
84- // the new values should win, regardless of the contents of the old values
105+ // Test non-default values of deprecated keys.
85106 v = config .New ()
86107 v .Set ("minify" , map [string ]any {
87108 "tdewolff" : map [string ]any {
109+ "css" : map [string ]any {
110+ "decimals" : 6 ,
111+ "keepcss2" : false ,
112+ },
88113 "html" : map [string ]any {
89- "keepConditionalComments" : false ,
90- "keepSpecialComments" : true ,
114+ "keepconditionalcomments" : false ,
91115 },
92116 "svg" : map [string ]any {
93- "decimal" : "5" ,
94- "precision" : "10" ,
117+ "decimals" : 7 ,
95118 },
96119 },
97120 })
98121
99122 conf = testconfig .GetTestConfigs (nil , v ).Base .Minify
100123
101- c .Assert (conf .Tdewolff .HTML .KeepSpecialComments , qt .Equals , true )
102- c .Assert (conf .Tdewolff .SVG .Precision , qt .Equals , 10 )
124+ c .Assert (conf .Tdewolff .CSS .Precision , qt .Equals , 6 )
125+ c .Assert (conf .Tdewolff .CSS .Version , qt .Equals , 0 )
126+ c .Assert (conf .Tdewolff .HTML .KeepSpecialComments , qt .Equals , false )
127+ c .Assert (conf .Tdewolff .SVG .Precision , qt .Equals , 7 )
103128}
0 commit comments