blob: f8b313afe0b622bdfe3a8aa64183a13e8aed0891 [file] [log] [blame]
Mathias Bynens79e2cf02020-05-29 16:46:17 +02001var normalize = require("./lib/normalize-selector.js");
2
3var tests = {
4 /*test*/"#foo .bar":
5 /*expected*/"#foo .bar",
6 /*test*/" #foo .bar ":
7 /*expected*/"#foo .bar",
8 /*test*/"#foo>.bar":
9 /*expected*/"#foo > .bar",
10 /*test*/" unit[ sh | quantity = \"200\" ] ":
11 /*expected*/"unit[sh|quantity=\"200\"]",
12 /*test*/"*~*>*.foo[ href *= \"/\" ]:hover>*[ data-foo = \"bar\" ]:focus+*.baz::after":
13 /*expected*/"* ~ * > *.foo[href*=\"/\"]:hover > *[data-foo=\"bar\"]:focus + *.baz::after",
14 /*test*/"@media screen and ( color ), projection and ( color )":
15 /*expected*/"@media screen and (color), projection and (color)",
16 /*test*/"@media handheld and ( min-width : 20em ), screen and ( min-width: 20em )":
17 /*expected*/"@media handheld and (min-width:20em), screen and (min-width:20em)",
18 /*test*/"@media screen and ( device-aspect-ratio : 2560 / 1440 )":
19 /*expected*/"@media screen and (device-aspect-ratio:2560/1440)",
20 /*test*/"((a ) (b(c ) ) d )>*[ data-foo = \"bar\" ]":
21 /*expected*/"((a)(b(c))d) > *[data-foo=\"bar\"]",
22 /*test*/"#foo[ a = \" b \\\" c\\\\\" ]":
23 /*expected*/"#foo[a=\" b \\\" c\\\\\"]",
24 /*test*/"#foo[ a = \"b\" i ]":
25 /*expected*/"#foo[a=\"b\" i]",
26 /*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3 /*c4*/ ":
27 /*expected*/".e1 .e2 .e3",
28 /*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3 ":
29 /*expected*/".e1 .e2 .e3",
30 /*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3":
31 /*expected*/".e1 .e2 .e3",
32 /*test*/"/*c1*/.e1/*c2*/.e2 /*c3*/ .e3":
33 /*expected*/".e1 .e2 .e3",
34 /*test*/".e1/*c2*/.e2 /*c3*/ .e3":
35 /*expected*/".e1 .e2 .e3"
36};
37
38var test, tmp;
39for (test in tests) {
40 if ((tmp = normalize(test)) && tmp === tests[test]) {
41 console.log("PASSED: " + test + " (" + tmp + ")");
42 }
43 else {
44 console.log("FAILED.\n Expected: " + tests[test] + "\n Received: " + tmp);
45 break;
46 }
47}
48
49console.log("Tests done.");