[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | exports.__esModule = true;
|
---|
| 4 | exports.testLossy = exports.parse = void 0;
|
---|
| 5 |
|
---|
| 6 | var _ava = _interopRequireDefault(require("ava"));
|
---|
| 7 |
|
---|
| 8 | var _index = _interopRequireDefault(require("../index"));
|
---|
| 9 |
|
---|
| 10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
---|
| 11 |
|
---|
| 12 | var parse = function parse(input, options, transform) {
|
---|
| 13 | return (0, _index["default"])(transform).processSync(input, options);
|
---|
| 14 | };
|
---|
| 15 |
|
---|
| 16 | exports.parse = parse;
|
---|
| 17 |
|
---|
| 18 | var testLossy = function testLossy(t, input, expected) {
|
---|
| 19 | var result = parse(input, {
|
---|
| 20 | lossless: false
|
---|
| 21 | });
|
---|
| 22 | t.deepEqual(result, expected);
|
---|
| 23 | };
|
---|
| 24 |
|
---|
| 25 | exports.testLossy = testLossy;
|
---|
| 26 | (0, _ava["default"])('combinator, descendant - single', testLossy, '.one .two', '.one .two');
|
---|
| 27 | (0, _ava["default"])('combinator, descendant - multiple', testLossy, '.one .two', '.one .two');
|
---|
| 28 | (0, _ava["default"])('combinator, child - space before', testLossy, '.one >.two', '.one>.two');
|
---|
| 29 | (0, _ava["default"])('combinator, child - space after', testLossy, '.one> .two', '.one>.two');
|
---|
| 30 | (0, _ava["default"])('combinator, sibling - space before', testLossy, '.one ~.two', '.one~.two');
|
---|
| 31 | (0, _ava["default"])('combinator, sibling - space after', testLossy, '.one~ .two', '.one~.two');
|
---|
| 32 | (0, _ava["default"])('combinator, adj sibling - space before', testLossy, '.one +.two', '.one+.two');
|
---|
| 33 | (0, _ava["default"])('combinator, adj sibling - space after', testLossy, '.one+ .two', '.one+.two');
|
---|
| 34 | (0, _ava["default"])('classes, extraneous spaces', testLossy, ' .h1 , .h2 ', '.h1,.h2');
|
---|
| 35 | (0, _ava["default"])('ids, extraneous spaces', testLossy, ' #h1 , #h2 ', '#h1,#h2');
|
---|
| 36 | (0, _ava["default"])('attribute, spaces in selector', testLossy, 'h1[ href *= "test" ]', 'h1[href*="test"]');
|
---|
| 37 | (0, _ava["default"])('attribute, insensitive flag 1', testLossy, '[href="test" i ]', '[href="test"i]');
|
---|
| 38 | (0, _ava["default"])('attribute, insensitive flag 2', testLossy, '[href=TEsT i ]', '[href=TEsT i]');
|
---|
| 39 | (0, _ava["default"])('attribute, insensitive flag 3', testLossy, '[href=test i ]', '[href=test i]');
|
---|
| 40 | (0, _ava["default"])('attribute, extreneous whitespace', testLossy, ' [href] , [class] ', '[href],[class]');
|
---|
| 41 | (0, _ava["default"])('namespace, space before', testLossy, ' postcss|button', 'postcss|button');
|
---|
| 42 | (0, _ava["default"])('namespace, space after', testLossy, 'postcss|button ', 'postcss|button');
|
---|
| 43 | (0, _ava["default"])('namespace - all elements, space before', testLossy, ' postcss|*', 'postcss|*');
|
---|
| 44 | (0, _ava["default"])('namespace - all elements, space after', testLossy, 'postcss|* ', 'postcss|*');
|
---|
| 45 | (0, _ava["default"])('namespace - all namespaces, space before', testLossy, ' *|button', '*|button');
|
---|
| 46 | (0, _ava["default"])('namespace - all namespaces, space after', testLossy, '*|button ', '*|button');
|
---|
| 47 | (0, _ava["default"])('namespace - all elements in all namespaces, space before', testLossy, ' *|*', '*|*');
|
---|
| 48 | (0, _ava["default"])('namespace - all elements in all namespaces, space after', testLossy, '*|* ', '*|*');
|
---|
| 49 | (0, _ava["default"])('namespace - all elements without namespace, space before', testLossy, ' |*', '|*');
|
---|
| 50 | (0, _ava["default"])('namespace - all elements without namespace, space after', testLossy, '|* ', '|*');
|
---|
| 51 | (0, _ava["default"])('namespace - tag with no namespace, space before', testLossy, ' |button', '|button');
|
---|
| 52 | (0, _ava["default"])('namespace - tag with no namespace, space after', testLossy, '|button ', '|button');
|
---|
| 53 | (0, _ava["default"])('namespace - inside attribute, space before', testLossy, ' [ postcss|href=test]', '[postcss|href=test]');
|
---|
| 54 | (0, _ava["default"])('namespace - inside attribute, space after', testLossy, '[postcss|href= test ] ', '[postcss|href=test]');
|
---|
| 55 | (0, _ava["default"])('namespace - inside attribute (2), space before', testLossy, ' [ postcss|href]', '[postcss|href]');
|
---|
| 56 | (0, _ava["default"])('namespace - inside attribute (2), space after', testLossy, '[postcss|href ] ', '[postcss|href]');
|
---|
| 57 | (0, _ava["default"])('namespace - inside attribute (3), space before', testLossy, ' [ *|href=test]', '[*|href=test]');
|
---|
| 58 | (0, _ava["default"])('namespace - inside attribute (3), space after', testLossy, '[*|href= test ] ', '[*|href=test]');
|
---|
| 59 | (0, _ava["default"])('namespace - inside attribute (4), space after', testLossy, '[|href= test ] ', '[|href=test]');
|
---|
| 60 | (0, _ava["default"])('tag - extraneous whitespace', testLossy, ' h1 , h2 ', 'h1,h2');
|
---|
| 61 | (0, _ava["default"])('tag - trailing comma', testLossy, 'h1, ', 'h1,');
|
---|
| 62 | (0, _ava["default"])('tag - trailing comma (1)', testLossy, 'h1,', 'h1,');
|
---|
| 63 | (0, _ava["default"])('tag - trailing comma (2)', testLossy, 'h1', 'h1');
|
---|
| 64 | (0, _ava["default"])('tag - trailing slash (1)', testLossy, 'h1\\ ', 'h1\\ ');
|
---|
| 65 | (0, _ava["default"])('tag - trailing slash (2)', testLossy, 'h1\\ h2\\', 'h1\\ h2\\');
|
---|
| 66 | (0, _ava["default"])('universal - combinator', testLossy, ' * + * ', '*+*');
|
---|
| 67 | (0, _ava["default"])('universal - extraneous whitespace', testLossy, ' * , * ', '*,*');
|
---|
| 68 | (0, _ava["default"])('universal - qualified universal selector', testLossy, '*[href] *:not(*.green)', '*[href] *:not(*.green)');
|
---|
| 69 | (0, _ava["default"])('nesting - spacing before', testLossy, ' &.class', '&.class');
|
---|
| 70 | (0, _ava["default"])('nesting - spacing after', testLossy, '&.class ', '&.class');
|
---|
| 71 | (0, _ava["default"])('nesting - spacing between', testLossy, '& .class ', '& .class');
|
---|
| 72 | (0, _ava["default"])('pseudo (single) - spacing before', testLossy, ' :after', ':after');
|
---|
| 73 | (0, _ava["default"])('pseudo (single) - spacing after', testLossy, ':after ', ':after');
|
---|
| 74 | (0, _ava["default"])('pseudo (double) - spacing before', testLossy, ' ::after', '::after');
|
---|
| 75 | (0, _ava["default"])('pseudo (double) - spacing after', testLossy, '::after ', '::after');
|
---|
| 76 | (0, _ava["default"])('pseudo - multiple', testLossy, ' *:target::before , a:after ', '*:target::before,a:after');
|
---|
| 77 | (0, _ava["default"])('pseudo - negated', testLossy, 'h1:not( .heading )', 'h1:not(.heading)');
|
---|
| 78 | (0, _ava["default"])('pseudo - negated with combinators (1)', testLossy, 'h1:not(.heading > .title) > h1', 'h1:not(.heading>.title)>h1');
|
---|
| 79 | (0, _ava["default"])('pseudo - negated with combinators (2)', testLossy, '.foo:nth-child(2n + 1)', '.foo:nth-child(2n+1)');
|
---|
| 80 | (0, _ava["default"])('pseudo - extra whitespace', testLossy, 'a:not( h2 )', 'a:not(h2)');
|
---|
| 81 | (0, _ava["default"])('comments - comment inside descendant selector', testLossy, "div /* wtf */.foo", "div /* wtf */.foo");
|
---|
| 82 | (0, _ava["default"])('comments - comment inside complex selector', testLossy, "div /* wtf */ > .foo", "div/* wtf */>.foo");
|
---|
| 83 | (0, _ava["default"])('comments - comment inside compound selector with space', testLossy, "div /* wtf */ .foo", "div /* wtf */.foo");
|
---|
| 84 | (0, _ava["default"])('@words - space before', testLossy, ' @media', '@media');
|
---|
| 85 | (0, _ava["default"])('@words - space after', testLossy, '@media ', '@media');
|
---|
| 86 | (0, _ava["default"])('@words - maintains space between', testLossy, '@media (min-width: 700px) and (orientation: landscape)', '@media (min-width: 700px) and (orientation: landscape)');
|
---|
| 87 | (0, _ava["default"])('@words - extraneous space between', testLossy, '@media (min-width: 700px) and (orientation: landscape)', '@media (min-width: 700px) and (orientation: landscape)');
|
---|
| 88 | (0, _ava["default"])('@words - multiple', testLossy, '@media (min-width: 700px), (min-height: 400px)', '@media (min-width: 700px),(min-height: 400px)'); |
---|