-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.test.js
66 lines (55 loc) · 1.73 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint-env jest */
const postcss = require('postcss');
const plugin = require('.');
function run(input, output, opts) {
return postcss([plugin(opts)]).process(input).then((result) => {
expect(result.css).toEqual(output);
expect(result.warnings()).toHaveLength(0);
});
}
it('adds tilda for modules paths', () => run(
'@value module from "module/module.css";',
'@value module from "~module/module.css";',
));
it('doesn\'t change relative paths', () => run(
'@value module from "./module/module.css";',
'@value module from "./module/module.css";',
));
it('doesn\'t change absolute paths', () => run(
'@value module from "/module/module.css";',
'@value module from "/module/module.css";',
));
it('adds tilda for modules paths inside composes', () => run(
'a { composes: selector from "module/module.css"; }',
'a { composes: selector from "~module/module.css"; }',
));
it('supports multiline imports', () => run(
`@value (
module,
module2
) from "module/module.css";`,
`@value (
module,
module2
) from "~module/module.css";`,
));
it('supports imports from scoped packages', () => run(
'@value module from "@scope/module/module.css"',
'@value module from "~@scope/module/module.css"',
));
it('adds tilda for namespaced global imports', () => run(
'@import "@scope/module/module.css"',
'@import "~@scope/module/module.css"',
));
it('adds tilda for modules global imports', () => run(
'@import "module/module.css"',
'@import "~module/module.css"',
));
it('doesn\'t change relative global imports', () => run(
'@import "./module/module.css"',
'@import "./module/module.css"',
));
it('doesn\'t change absolute global imports', () => run(
'@import "/module/module.css"',
'@import "/module/module.css"',
));