-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
51 lines (47 loc) · 1.16 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
const postcss = require("postcss");
const syntaxLess = require("postcss-less");
const plugin = require("./");
async function run(input, output, opts = {}) {
let result = await postcss([plugin(opts)]).process(input, {
from: undefined,
syntax: syntaxLess
});
expect(result.css).toEqual(output);
expect(result.warnings()).toHaveLength(0);
}
it("can convert variables in css", async () => {
await run(
":root { --color: black; --size: 15px; } div { --size: 20px; background: var(--color); font-size: var(--size) } p { font-size: var(--size) }",
" @color: black; @size: 15px; div { @size: 20px; background: @color; font-size: @size } p { font-size: @size }",
{}
);
});
it("can convert variables in less", async () => {
await run(
`:root { --color: black; }
@prefix: ~'flyfly';
.@prefix {
&-foo {
--color: red;
// --c: 10px;
&-bar {
background: var(--color, blue);
}
}
}
`,
` @color: black;
@prefix: ~'flyfly';
.@prefix {
&-foo {
@color: red;
// --c: 10px;
&-bar {
background: @color;
}
}
}
`,
{}
);
});