@@ -14,24 +14,70 @@ describe("processor", () => {
1414 check (
1515 "it should extract an import within a :local" ,
1616 `:local(.exportName) { extends: importName from "path/library.css"; other: rule; }` ,
17- `:import("path/library.css") {importName: __tmp_importName_rand0ml0l0l; }\n:local(.exportName) { extends: __tmp_importName_rand0ml0l0l; other: rule; }` ,
17+ `
18+ :import("path/library.css") {
19+ importName: __tmp_importName_rand0ml0l0l; }
20+ :local(.exportName) { extends: __tmp_importName_rand0ml0l0l; other: rule; }` ,
1821 [ "rand0ml0l0l" ]
1922 )
2023
2124 check (
2225 "it should not care if single-quotes are used" ,
2326 `:local(.exportName) { extends: importName from 'path/library.css'; other: rule; }` ,
24- `:import("path/library.css") {importName: __tmp_importName_rand0ml0l0l; }\n:local(.exportName) { extends: __tmp_importName_rand0ml0l0l; other: rule; }` ,
27+ `
28+ :import("path/library.css") {
29+ importName: __tmp_importName_rand0ml0l0l; }
30+ :local(.exportName) { extends: __tmp_importName_rand0ml0l0l; other: rule; }` ,
2531 [ "rand0ml0l0l" ]
2632 )
2733
2834 check (
2935 "should import multiple classes on a single line" ,
3036 `:local(.exportName) { extends: importName secondImport from 'path/library.css'; other: rule; }` ,
31- `:import("path/library.css") {importName: __tmp_importName_rand0ml0l0l;secondImport: __tmp_secondImport_rand0ml1l1l; }\n:local(.exportName) { extends: __tmp_importName_rand0ml0l0l __tmp_secondImport_rand0ml1l1l; other: rule; }` ,
37+ `
38+ :import("path/library.css") {
39+ importName: __tmp_importName_rand0ml0l0l;
40+ secondImport: __tmp_secondImport_rand0ml1l1l; }
41+ :local(.exportName) { extends: __tmp_importName_rand0ml0l0l __tmp_secondImport_rand0ml1l1l; other: rule; }` ,
3242 [ "rand0ml0l0l" , "rand0ml1l1l" ]
3343 )
34- it ( "should consolidate imports by file for multiple files and multiple classes" )
44+
45+ check (
46+ "should consolidate imports by file for multiple files and multiple classes" ,
47+
48+ /* INPUT */
49+ `
50+ :local(.exportName) {
51+ extends: importName secondImport from 'path/library.css';
52+ other: rule;
53+ }
54+ :local(.otherExport) {
55+ extends: thirdImport from 'path/library.css';
56+ extends: otherLibImport from 'path/other-lib.css';
57+ }` ,
58+
59+ /* OUTPUT */
60+ `
61+ :import("path/other-lib.css") {
62+ otherLibImport: __tmp_otherLibImport_rand0ml3l3l3;
63+ }
64+ :import("path/library.css") {
65+ importName: __tmp_importName_rand0ml0l0l;
66+ secondImport: __tmp_secondImport_rand0ml1l1l;
67+ thirdImport: __tmp_thirdImport_rand0ml2l2l;
68+ }
69+ :local(.exportName) {
70+ extends: __tmp_importName_rand0ml0l0l __tmp_secondImport_rand0ml1l1l;
71+ other: rule;
72+ }
73+ :local(.otherExport) {
74+ extends: __tmp_thirdImport_rand0ml2l2l;
75+ extends: __tmp_otherLibImport_rand0ml3l3l3;
76+ }` ,
77+ /* RANDOMS */
78+ [ "rand0ml0l0l" , "rand0ml1l1l" , "rand0ml2l2l" , "rand0ml3l3l3" ]
79+ )
80+
3581 it ( "should ignore imports not inside a :local" )
3682 it ( "should ignore imports not inside our rule whitelist" )
3783} )
0 commit comments