@@ -14,11 +14,11 @@ pub mod tests {
1414 fn success ( ) {
1515 css_inline ( )
1616 . arg ( "tests/example.html" )
17- . arg ( "--output-filename-prefix=inlined.keep-style-tags ." )
17+ . arg ( "--output-filename-prefix=inlined.success ." )
1818 . assert ( )
1919 . success ( )
2020 . stdout ( "tests/example.html: SUCCESS\n " ) ;
21- let content = fs:: read_to_string ( "tests/inlined.keep-style-tags .example.html" ) . unwrap ( ) ;
21+ let content = fs:: read_to_string ( "tests/inlined.success .example.html" ) . unwrap ( ) ;
2222 assert_eq ! (
2323 content,
2424 "<html><head>\n \
@@ -38,10 +38,11 @@ pub mod tests {
3838 css_inline ( )
3939 . arg ( "tests/example.html" )
4040 . arg ( "--keep-style-tags" )
41+ . arg ( "--output-filename-prefix=inlined.keep-style-tags." )
4142 . assert ( )
4243 . success ( )
4344 . stdout ( "tests/example.html: SUCCESS\n " ) ;
44- let content = fs:: read_to_string ( "tests/inlined.example.html" ) . unwrap ( ) ;
45+ let content = fs:: read_to_string ( "tests/inlined.keep-style-tags. example.html" ) . unwrap ( ) ;
4546 assert_eq ! (
4647 content,
4748 "<html><head>\n \n \
@@ -55,6 +56,49 @@ pub mod tests {
5556 )
5657 }
5758
59+ #[ test]
60+ fn dont_inline_styles ( ) {
61+ css_inline ( )
62+ . arg ( "tests/example.html" )
63+ . arg ( "--inline-style-tags=false" )
64+ . arg ( "--output-filename-prefix=inlined.dont-inline-styles." )
65+ . assert ( )
66+ . success ( )
67+ . stdout ( "tests/example.html: SUCCESS\n " ) ;
68+ let content = fs:: read_to_string ( "tests/inlined.dont-inline-styles.example.html" ) . unwrap ( ) ;
69+ assert_eq ! (
70+ content,
71+ "<html><head>\n \n \n \n \
72+ </head>\n \
73+ <body>\n \
74+ <a class=\" test-class\" href=\" https://example.com\" >Test</a>\n \
75+ <h1>Test</h1>\n \n \n \
76+ </body></html>"
77+ )
78+ }
79+
80+ #[ test]
81+ fn no_remote_stylesheets ( ) {
82+ css_inline ( )
83+ . arg ( "tests/example.html" )
84+ . arg ( "--load-remote-stylesheets=false" )
85+ . arg ( "--output-filename-prefix=inlined.no-remote-stylesheets." )
86+ . assert ( )
87+ . success ( )
88+ . stdout ( "tests/example.html: SUCCESS\n " ) ;
89+ let content =
90+ fs:: read_to_string ( "tests/inlined.no-remote-stylesheets.example.html" ) . unwrap ( ) ;
91+ assert_eq ! (
92+ content,
93+ "<html><head>\n \n \n \n \
94+ </head>\n \
95+ <body>\n \
96+ <a class=\" test-class\" href=\" https://example.com\" style=\" color: #ffffff;\" >Test</a>\n \
97+ <h1 style=\" text-decoration: none;\" >Test</h1>\n \n \n \
98+ </body></html>"
99+ )
100+ }
101+
58102 #[ test]
59103 #[ cfg( feature = "stylesheet-cache" ) ]
60104 fn cache_valid ( ) {
@@ -175,11 +219,88 @@ pub mod tests {
175219 }
176220
177221 #[ test_case( "--help" , "css-inline inlines CSS into HTML" ) ]
222+ #[ test_case( "-h" , "css-inline inlines CSS into HTML" ) ]
178223 #[ test_case( "--version" , "css-inline" ) ]
224+ #[ test_case( "-v" , "css-inline" ) ]
179225 fn args ( arg : & str , expected : & str ) {
180226 let stdout = css_inline ( ) . arg ( arg) . assert ( ) . success ( ) . to_string ( ) ;
181227 assert ! ( stdout. contains( expected) , "{}" , stdout) ;
182228 }
229+
230+ #[ test]
231+ fn flag_requires_value_but_none_provided ( ) {
232+ css_inline ( )
233+ . arg ( "--base-url" )
234+ . assert ( )
235+ . failure ( )
236+ . stderr ( "Error parsing arguments: Flag --base-url requires a value\n " ) ;
237+ }
238+
239+ #[ test]
240+ fn invalid_multi_character_short_flag ( ) {
241+ css_inline ( )
242+ . arg ( "-abc" )
243+ . assert ( )
244+ . failure ( )
245+ . stderr ( "Error parsing arguments: Invalid flag: -abc\n " ) ;
246+ }
247+
248+ #[ test]
249+ fn keep_link_tags_flag ( ) {
250+ css_inline ( )
251+ . arg ( "tests/example.html" )
252+ . arg ( "--keep-link-tags" )
253+ . arg ( "--output-filename-prefix=inlined.keep-link-tags." )
254+ . assert ( )
255+ . success ( )
256+ . stdout ( "tests/example.html: SUCCESS\n " ) ;
257+ }
258+
259+ #[ test]
260+ fn unknown_short_flag ( ) {
261+ css_inline ( )
262+ . arg ( "-b" )
263+ . assert ( )
264+ . failure ( )
265+ . stderr ( "Unknown flag: b\n " ) ;
266+ }
267+
268+ #[ test]
269+ fn unknown_boolean_flag ( ) {
270+ css_inline ( )
271+ . arg ( "--unknown-flag" )
272+ . assert ( )
273+ . failure ( )
274+ . stderr ( "Unknown flag: unknown-flag\n " ) ;
275+ }
276+
277+ #[ test]
278+ fn unknown_flag_with_value ( ) {
279+ css_inline ( )
280+ . arg ( "--unknown-flag=value" )
281+ . assert ( )
282+ . failure ( )
283+ . stderr ( "Unknown flag: --unknown-flag\n " ) ;
284+ }
285+
286+ #[ test]
287+ fn invalid_boolean_value_for_flag ( ) {
288+ css_inline ( )
289+ . arg ( "--inline-style-tags=invalid" )
290+ . assert ( )
291+ . failure ( )
292+ . stderr ( "Failed to parse value 'invalid' for flag 'inline-style-tags': provided string was not `true` or `false`\n " ) ;
293+ }
294+
295+ #[ test]
296+ #[ cfg( feature = "stylesheet-cache" ) ]
297+ fn invalid_numeric_value_for_cache_size ( ) {
298+ css_inline ( )
299+ . arg ( "--cache-size=invalid" )
300+ . assert ( )
301+ . failure ( )
302+ . stderr ( "Failed to parse value 'invalid' for flag 'cache-size': invalid digit found in string\n " ) ;
303+ }
183304}
184305
185306#[ cfg( not( feature = "cli" ) ) ]
0 commit comments