/
issue927.js
52 lines (45 loc) · 1.06 KB
/
issue927.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
import postcss from 'postcss';
import nano from '..';
const fixture = `
div{
grid-column: span 2;
}
p{
columns: 2 auto;
}
`;
const expected = `div{grid-column:span 2}p{column-count:2}`;
test('it should compress the columns (old plugin syntax)', () => {
const processor = postcss([
postcss.plugin('cloner', () => {
return (css) => {
css.walkAtRules((rule) => {
css.prepend(rule.clone());
rule.remove();
});
};
}),
nano(),
]);
return processor
.process(fixture, { from: undefined })
.then((r) => expect(r.css).toBe(expected));
});
test('it should compress the columns (new plugin syntax)', () => {
const plugin = () => {
return {
postcssPlugin: 'cloner',
Once(root) {
root.walkAtRules((rule) => {
root.prepend(rule.clone());
rule.remove();
});
},
};
};
plugin.postcss = true;
const processor = postcss([plugin, nano()]);
return processor
.process(fixture, { from: undefined })
.then((r) => expect(r.css).toBe(expected));
});