This repository has been archived by the owner on Apr 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.js
79 lines (71 loc) · 1.49 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
67
68
69
70
71
72
73
74
75
76
77
78
79
var postcss = require('postcss');
var plugin = require('./');
function run(input, output, opts) {
return postcss([ plugin(opts) ]).process(input)
.then(result => {
expect(result.css).toEqual(output);
expect(result.warnings().length).toBe(0);
});
}
it('sorts rules', () => {
return run(`a{
border: 1px solid black;
color: red;
background-color: red;
}
div{
padding: 10px;
margin: 20px;
color: red;
background-color: red;
}
.class {
flex: 1;
display-flex: 10px;
}
#some {
background-image: url('something');
align-items: center;
}`,
`a{
background-color: red;
border: 1px solid black;
color: red;
}
div{
background-color: red;
color: red;
margin: 20px;
padding: 10px;
}
.class {
display-flex: 10px;
flex: 1;
}
#some {
align-items: center;
background-image: url('something');
}`
, { });
});
it('sorts nested rules', () => {
return run( `div{
color: red;
border: 1px solid black;
background-color: red;
.class {
color: red;
border: 1px solid black;
}
}`,
`div{
background-color: red;
border: 1px solid black;
color: red;
.class {
border: 1px solid black;
color: red;
}
}`
, { });
});