1
0
mirror of https://github.com/thangisme/notes.git synced 2024-10-31 23:37:18 -04:00
notes/node_modules/normalize-selector/tests.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

50 lines
1.8 KiB
JavaScript

var normalize = require("./lib/normalize-selector.js");
var tests = {
/*test*/"#foo .bar":
/*expected*/"#foo .bar",
/*test*/" #foo .bar ":
/*expected*/"#foo .bar",
/*test*/"#foo>.bar":
/*expected*/"#foo > .bar",
/*test*/" unit[ sh | quantity = \"200\" ] ":
/*expected*/"unit[sh|quantity=\"200\"]",
/*test*/"*~*>*.foo[ href *= \"/\" ]:hover>*[ data-foo = \"bar\" ]:focus+*.baz::after":
/*expected*/"* ~ * > *.foo[href*=\"/\"]:hover > *[data-foo=\"bar\"]:focus + *.baz::after",
/*test*/"@media screen and ( color ), projection and ( color )":
/*expected*/"@media screen and (color), projection and (color)",
/*test*/"@media handheld and ( min-width : 20em ), screen and ( min-width: 20em )":
/*expected*/"@media handheld and (min-width:20em), screen and (min-width:20em)",
/*test*/"@media screen and ( device-aspect-ratio : 2560 / 1440 )":
/*expected*/"@media screen and (device-aspect-ratio:2560/1440)",
/*test*/"((a ) (b(c ) ) d )>*[ data-foo = \"bar\" ]":
/*expected*/"((a)(b(c))d) > *[data-foo=\"bar\"]",
/*test*/"#foo[ a = \" b \\\" c\\\\\" ]":
/*expected*/"#foo[a=\" b \\\" c\\\\\"]",
/*test*/"#foo[ a = \"b\" i ]":
/*expected*/"#foo[a=\"b\" i]",
/*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3 /*c4*/ ":
/*expected*/".e1 .e2 .e3",
/*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3 ":
/*expected*/".e1 .e2 .e3",
/*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3":
/*expected*/".e1 .e2 .e3",
/*test*/"/*c1*/.e1/*c2*/.e2 /*c3*/ .e3":
/*expected*/".e1 .e2 .e3",
/*test*/".e1/*c2*/.e2 /*c3*/ .e3":
/*expected*/".e1 .e2 .e3"
};
var test, tmp;
for (test in tests) {
if ((tmp = normalize(test)) && tmp === tests[test]) {
console.log("PASSED: " + test + " (" + tmp + ")");
}
else {
console.log("FAILED.\n Expected: " + tests[test] + "\n Received: " + tmp);
break;
}
}
console.log("Tests done.");