From d299a746702d8225d7465e653e7f193197e02fd2 Mon Sep 17 00:00:00 2001 From: Liam Newman Date: Wed, 1 May 2019 16:05:25 -0700 Subject: [PATCH] Add tests for #1233 Fixes #1233 --- js/test/generated/beautify-css-tests.js | 54 +++++++++- python/cssbeautifier/tests/generated/tests.py | 52 +++++++++- test/data/css/tests.js | 99 +++++++++++++++---- 3 files changed, 181 insertions(+), 24 deletions(-) diff --git a/js/test/generated/beautify-css-tests.js b/js/test/generated/beautify-css-tests.js index 830290a7..d3fcceae 100644 --- a/js/test/generated/beautify-css-tests.js +++ b/js/test/generated/beautify-css-tests.js @@ -10555,6 +10555,23 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea 'div [attr] :not(.class) {\n' + ' color: red;\n' + '}'); + + // Issue #1233 + t( + '.one {\n' + + ' color: #FFF;\n' + + ' // pseudo-element\n' + + ' span:not(*::selection) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}\n' + + '.two {\n' + + ' color: #000;\n' + + ' // pseudo-class\n' + + ' span:not(*:active) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}'); //============================================================ @@ -10578,9 +10595,9 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea //============================================================ - // Issue #645 + // Issue #645, #1233 reset_options(); - set_name('Issue #645'); + set_name('Issue #645, #1233'); opts.selector_separator_newline = true; opts.preserve_newlines = true; opts.newline_between_rules = true; @@ -10602,6 +10619,39 @@ function run_css_tests(test_obj, Urlencoded, js_beautify, html_beautify, css_bea '}\n' + '\n' + '/* Comment after last rule */'); + t( + '.one {\n' + + ' color: #FFF;\n' + + ' // pseudo-element\n' + + ' span:not(*::selection) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}\n' + + '.two {\n' + + ' color: #000;\n' + + ' // pseudo-class\n' + + ' span:not(*:active) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}', + // -- output -- + '.one {\n' + + ' color: #FFF;\n' + + '\n' + + ' // pseudo-element\n' + + ' span:not(*::selection) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}\n' + + '\n' + + '.two {\n' + + ' color: #000;\n' + + '\n' + + ' // pseudo-class\n' + + ' span:not(*:active) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}'); //============================================================ diff --git a/python/cssbeautifier/tests/generated/tests.py b/python/cssbeautifier/tests/generated/tests.py index f85fe3cf..29bf14b2 100644 --- a/python/cssbeautifier/tests/generated/tests.py +++ b/python/cssbeautifier/tests/generated/tests.py @@ -10438,6 +10438,23 @@ class CSSBeautifierTest(unittest.TestCase): 'div [attr] :not(.class) {\n' + ' color: red;\n' + '}') + + # Issue #1233 + t( + '.one {\n' + + ' color: #FFF;\n' + + ' // pseudo-element\n' + + ' span:not(*::selection) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}\n' + + '.two {\n' + + ' color: #000;\n' + + ' // pseudo-class\n' + + ' span:not(*:active) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}') #============================================================ @@ -10460,7 +10477,7 @@ class CSSBeautifierTest(unittest.TestCase): #============================================================ - # Issue #645 + # Issue #645, #1233 self.reset_options() self.options.selector_separator_newline = true self.options.preserve_newlines = true @@ -10483,6 +10500,39 @@ class CSSBeautifierTest(unittest.TestCase): '}\n' + '\n' + '/* Comment after last rule */') + t( + '.one {\n' + + ' color: #FFF;\n' + + ' // pseudo-element\n' + + ' span:not(*::selection) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}\n' + + '.two {\n' + + ' color: #000;\n' + + ' // pseudo-class\n' + + ' span:not(*:active) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}', + # -- output -- + '.one {\n' + + ' color: #FFF;\n' + + '\n' + + ' // pseudo-element\n' + + ' span:not(*::selection) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}\n' + + '\n' + + '.two {\n' + + ' color: #000;\n' + + '\n' + + ' // pseudo-class\n' + + ' span:not(*:active) {\n' + + ' margin-top: 0;\n' + + ' }\n' + + '}') #============================================================ diff --git a/test/data/css/tests.js b/test/data/css/tests.js index 74b0b089..570515a5 100644 --- a/test/data/css/tests.js +++ b/test/data/css/tests.js @@ -1361,6 +1361,25 @@ exports.test_data = { ' color: red;', '}' ] + }, + { + comment: "Issue #1233", + unchanged: [ + '.one {', + ' color: #FFF;', + ' // pseudo-element', + ' span:not(*::selection) {', + ' margin-top: 0;', + ' }', + '}', + '.two {', + ' color: #000;', + ' // pseudo-class', + ' span:not(*:active) {', + ' margin-top: 0;', + ' }', + '}' + ] } ] }, { @@ -1386,7 +1405,7 @@ exports.test_data = { ] }] }, { - name: "Issue #645", + name: "Issue #645, #1233", description: "", options: [ { name: "selector_separator_newline", value: "true" }, @@ -1395,26 +1414,64 @@ exports.test_data = { ], tests: [{ - unchanged: [ - '/* Comment above first rule */', - '', - 'body {', - ' display: none;', - '}', - '', - '/* Comment between rules */', - '', - 'ul,', - '', - '/* Comment between selectors */', - '', - 'li {', - ' display: none;', - '}', - '', - '/* Comment after last rule */' - ] - }] + unchanged: [ + '/* Comment above first rule */', + '', + 'body {', + ' display: none;', + '}', + '', + '/* Comment between rules */', + '', + 'ul,', + '', + '/* Comment between selectors */', + '', + 'li {', + ' display: none;', + '}', + '', + '/* Comment after last rule */' + ] + }, + { + input: [ + '.one {', + ' color: #FFF;', + ' // pseudo-element', + ' span:not(*::selection) {', + ' margin-top: 0;', + ' }', + '}', + '.two {', + ' color: #000;', + ' // pseudo-class', + ' span:not(*:active) {', + ' margin-top: 0;', + ' }', + '}' + ], + output: [ + '.one {', + ' color: #FFF;', + '', + ' // pseudo-element', + ' span:not(*::selection) {', + ' margin-top: 0;', + ' }', + '}', + '', + '.two {', + ' color: #000;', + '', + ' // pseudo-class', + ' span:not(*:active) {', + ' margin-top: 0;', + ' }', + '}' + ] + } + ] }, { name: "Extend Tests", description: "Test for '@extend'",