From 9e2397ce8da494dd3c4bbf12824087a9e32ed340 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Tue, 11 Aug 2020 14:58:41 -0400 Subject: [PATCH] refactor `!important` tests into separate file --- tests/addition.rs | 10 ++++++++++ tests/color.rs | 40 ---------------------------------------- tests/important.rs | 35 +++++++++++++++++++++++++++++++++++ tests/misc.rs | 19 ------------------- tests/subtraction.rs | 30 ++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+), 59 deletions(-) create mode 100644 tests/important.rs diff --git a/tests/addition.rs b/tests/addition.rs index fd431e2..bacac87 100644 --- a/tests/addition.rs +++ b/tests/addition.rs @@ -289,6 +289,16 @@ test!( }", "a {\n color: a, b1;\n}\n" ); +test!( + color_plus_ident, + "a {\n color: red + foo;\n}\n", + "a {\n color: redfoo;\n}\n" +); +test!( + ident_plus_color, + "a {\n color: foo + red;\n}\n", + "a {\n color: foored;\n}\n" +); error!( map_lhs_add, "a {color: (a: b) + 1;}", "Error: (a: b) isn't a valid CSS value." diff --git a/tests/color.rs b/tests/color.rs index 86bd048..5a7e98a 100644 --- a/tests/color.rs +++ b/tests/color.rs @@ -192,46 +192,6 @@ test!( "a {\n color: hsla($hue: 193, $saturation: 67%, $lightness: 99, $alpha: .6);\n}\n", "a {\n color: rgba(251, 253, 254, 0.6);\n}\n" ); -test!( - color_plus_ident, - "a {\n color: red + foo;\n}\n", - "a {\n color: redfoo;\n}\n" -); -test!( - ident_plus_color, - "a {\n color: foo + red;\n}\n", - "a {\n color: foored;\n}\n" -); -test!( - color_minus_ident, - "a {\n color: red - foo;\n}\n", - "a {\n color: red-foo;\n}\n" -); -test!( - color_minus_dbl_quote_ident, - "a {\n color: red - \"foo\";\n}\n", - "a {\n color: red-\"foo\";\n}\n" -); -test!( - color_minus_sgl_quote_ident, - "a {\n color: red - 'foo';\n}\n", - "a {\n color: red-\"foo\";\n}\n" -); -test!( - color_minus_important, - "a {\n color: red - !important;\n}\n", - "a {\n color: red-!important;\n}\n" -); -test!( - color_minus_null, - "a {\n color: red - null;\n}\n", - "a {\n color: red-;\n}\n" -); -test!( - ident_minus_color, - "a {\n color: foo - red;\n}\n", - "a {\n color: foo-red;\n}\n" -); test!( hue, "a {\n color: hue(hsl(193, 67%, 28%));\n}\n", diff --git a/tests/important.rs b/tests/important.rs new file mode 100644 index 0000000..14bb543 --- /dev/null +++ b/tests/important.rs @@ -0,0 +1,35 @@ +#![cfg(test)] + +#[macro_use] +mod macros; + +test!( + keyword_important_lowercase, + "a {\n height: !important;\n}\n", + "a {\n height: !important;\n}\n" +); +test!( + keyword_important_uppercase, + "a {\n height: !IMPORTANT;\n}\n", + "a {\n height: !important;\n}\n" +); +test!( + keyword_important_at_start_of_list, + "a {\n height: !important 1 2 3;\n}\n", + "a {\n height: !important 1 2 3;\n}\n" +); +test!( + keyword_important_at_end_of_list, + "a {\n height: 1 2 3 !important;\n}\n", + "a {\n height: 1 2 3 !important;\n}\n" +); +test!( + keyword_important_inside_list, + "a {\n color: 1 2 !important 3 4;\n}\n", + "a {\n color: 1 2 !important 3 4;\n}\n" +); +test!( + whitespace_after_exclamation, + "a {\n color: ! important;\n}\n", + "a {\n color: !important;\n}\n" +); diff --git a/tests/misc.rs b/tests/misc.rs index 09dbfce..22d8f1d 100644 --- a/tests/misc.rs +++ b/tests/misc.rs @@ -12,16 +12,6 @@ test!( "a {\n foo: --webkit-bar-baz;\n}\n" ); test!(ident_with_num, "el1 {\n a: b;\n}\n"); -test!(keyword_important, "a {\n height: 1 !important;\n}\n"); -test!( - keyword_important_uppercase, - "a {\n height: 1 !IMPORTANT;\n}\n", - "a {\n height: 1 !important;\n}\n" -); -test!( - keyword_important_not_at_end, - "a {\n height: !important 1;\n}\n" -); test!( emits_double_newline_between_unrelated_styles, "a {\n color: red;\n}\n\nb {\n color: blue;\n}\n" @@ -88,15 +78,6 @@ test!( "a {\n color: inspect((((((a))))));\n}\n", "a {\n color: a;\n}\n" ); -test!( - allow_spaces_after_exclamation_point, - "a {\n color: foo ! important;\n}\n", - "a {\n color: foo !important;\n}\n" -); -test!( - values_after_important, - "a {\n color: foo bar !important hux baz;\n}\n" -); test!( no_space_between_colon_and_style_variable, "$base-color: #036;\na {\n color:lighten($base-color, 5%);\n}", diff --git a/tests/subtraction.rs b/tests/subtraction.rs index 5594cc1..9d1a590 100644 --- a/tests/subtraction.rs +++ b/tests/subtraction.rs @@ -255,6 +255,36 @@ test!( }", "a {\n color: 1-a, b;\n}\n" ); +test!( + color_minus_unquoted, + "a {\n color: red - foo;\n}\n", + "a {\n color: red-foo;\n}\n" +); +test!( + color_minus_dblquoted, + "a {\n color: red - \"foo\";\n}\n", + "a {\n color: red-\"foo\";\n}\n" +); +test!( + color_minus_sglquoted, + "a {\n color: red - 'foo';\n}\n", + "a {\n color: red-\"foo\";\n}\n" +); +test!( + color_minus_important, + "a {\n color: red - !important;\n}\n", + "a {\n color: red-!important;\n}\n" +); +test!( + color_minus_null, + "a {\n color: red - null;\n}\n", + "a {\n color: red-;\n}\n" +); +test!( + ident_minus_color, + "a {\n color: foo - red;\n}\n", + "a {\n color: foo-red;\n}\n" +); error!( number_minus_color, "a {\n color: 1 - #abc;\n}\n", "Error: Undefined operation \"1 - #abc\"."