Skip to content

Commit 5acecc9

Browse files
committed
Update dependencies
This commit also updates test format because PostCSS v6 keeps `raws` property as much as possible.
1 parent 7955635 commit 5acecc9

23 files changed

+290
-167
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
"url": "https://github.com/hail2u/node-css-mqpacker/issues"
1111
},
1212
"dependencies": {
13-
"minimist": "^1.1.1",
14-
"postcss": "^5.0.0"
13+
"minimist": "^1.2.0",
14+
"postcss": "^6.0.0"
1515
},
1616
"devDependencies": {
17-
"nodeunit": "^0.10.2"
17+
"nodeunit": "^0.11.0"
1818
},
1919
"engines": {
2020
"node": ">=5.0.0"

test/css-mqpacker_test.js

Lines changed: 72 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,120 @@
11
"use strict";
22

3-
var fs = require("fs");
4-
var path = require("path");
5-
var postcss = require("postcss");
3+
const fs = require("fs");
4+
const path = require("path");
5+
const postcss = require("postcss");
66

7-
var mqpacker = require("../index");
7+
const mqpacker = require("../index");
88

9-
exports["Public API"] = function (test) {
10-
var expected;
11-
var input = "@media (min-width:1px) {\n .foo {\n color: black\n }\n}";
12-
expected = postcss().process(input).css;
9+
exports["Public API"] = (test) => {
10+
const input = `.foo {
11+
z-index: 0;
12+
}
1313
14-
test.expect(2);
14+
@media (min-width:1px) {
15+
.foo {
16+
z-index: 1;
17+
}
18+
}
19+
`;
20+
const expected = postcss().process(input).css;
1521

22+
test.expect(2);
1623
test.strictEqual(
1724
postcss([mqpacker()]).process(input).css,
1825
expected
1926
);
20-
2127
test.strictEqual(
2228
mqpacker.pack(input).css,
2329
expected
2430
);
25-
2631
test.done();
2732
};
2833

29-
exports["Option: PostCSS options"] = function (test) {
30-
var expected;
31-
var input = "@media (min-width:1px) {\n .foo {\n color: black\n }\n}\n\n/*# sourceMappingURL=from.css.map */\n";
32-
var opts = {
34+
exports["Option: PostCSS options"] = (test) => {
35+
const input = `.foo {
36+
z-index: 0;
37+
}
38+
39+
@media (min-width:1px) {
40+
.foo {
41+
z-index: 1;
42+
}
43+
}
44+
45+
/*# sourceMappingURL=from.css.map */
46+
`;
47+
const opts = {
3348
from: "from.css",
3449
map: {
3550
inline: false
3651
}
3752
};
38-
var processed = mqpacker.pack(input, opts);
39-
expected = postcss().process(input, opts);
53+
const expected = postcss().process(input, opts);
54+
const processed = mqpacker.pack(input, opts);
4055

4156
test.expect(2);
42-
4357
test.strictEqual(
4458
processed.css,
4559
expected.css
4660
);
47-
4861
test.deepEqual(
4962
processed.map,
5063
expected.map
5164
);
52-
5365
test.done();
5466
};
5567

56-
exports["Option: sort"] = function (test) {
57-
var expected = "@media (min-width: 1px) {\n .foo {\n z-index: 1\n }\n}\n@media (min-width: 2px) {\n .foo {\n z-index: 2\n }\n}";
58-
var input = "@media (min-width: 2px) { .foo { z-index: 2 } }@media (min-width: 1px) { .foo { z-index: 1 } }";
59-
var opts = {
68+
exports["Option: sort"] = (test) => {
69+
const expected = `.foo {
70+
z-index: 0;
71+
}
72+
73+
@media (min-width: 1px) {
74+
.foo {
75+
z-index: 1;
76+
}
77+
}
78+
79+
@media (min-width: 2px) {
80+
.foo {
81+
z-index: 2;
82+
}
83+
}
84+
`;
85+
const input = `.foo {
86+
z-index: 0;
87+
}
88+
89+
@media (min-width: 2px) {
90+
.foo {
91+
z-index: 2;
92+
}
93+
}
94+
95+
@media (min-width: 1px) {
96+
.foo {
97+
z-index: 1;
98+
}
99+
}
100+
`;
101+
const opts = {
60102
sort: true
61103
};
62104

63105
test.expect(4);
64-
65106
test.notStrictEqual(
66107
mqpacker.pack(input).css,
67108
expected
68109
);
69-
70110
test.strictEqual(
71111
mqpacker.pack(input, opts).css,
72112
expected
73113
);
74-
75114
test.notStrictEqual(
76115
postcss([mqpacker()]).process(input).css,
77116
postcss([mqpacker(opts)]).process(input).css
78117
);
79-
80118
test.strictEqual(
81119
mqpacker.pack(input, {
82120
sort: function (c, d) {
@@ -85,29 +123,25 @@ exports["Option: sort"] = function (test) {
85123
}).css,
86124
expected
87125
);
88-
89126
test.done();
90127
};
91128

92-
exports["Real CSS"] = function (test) {
93-
var testCases = fs.readdirSync(path.join(__dirname, "fixtures"));
94-
95-
var loadExpected = function (file) {
129+
exports["Real CSS"] = (test) => {
130+
const testCases = fs.readdirSync(path.join(__dirname, "fixtures"));
131+
const loadExpected = (file) => {
96132
file = path.join(__dirname, "expected", file);
97133

98134
return fs.readFileSync(file, "utf8");
99135
};
100-
101-
var loadInput = function (file) {
136+
const loadInput = (file) => {
102137
file = path.join(__dirname, "fixtures", file);
103138

104139
return fs.readFileSync(file, "utf8");
105140
};
106141

107142
test.expect(testCases.length);
108-
109-
testCases.forEach(function (testCase) {
110-
var opts = {
143+
testCases.forEach((testCase) => {
144+
const opts = {
111145
sort: false
112146
};
113147

@@ -121,6 +155,5 @@ exports["Real CSS"] = function (test) {
121155
testCase
122156
);
123157
});
124-
125158
test.done();
126159
};

test/expected/keep-query-order.css

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
.foo {
2+
z-index: 0;
3+
}
4+
15
@media (min-width: 99px) {
2-
.foo {
3-
z-index: 1
4-
}
5-
.bar {
6-
z-index: 2
7-
}
6+
.foo {
7+
z-index: 1;
8+
}
9+
.bar {
10+
z-index: 2;
11+
}
812
}
13+
914
@media (min-width: 999px) {
10-
.foo {
11-
z-index: 3
12-
}
15+
.foo {
16+
z-index: 3;
17+
}
1318
}

test/expected/last-comment.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
/* Comment */
1010

1111
@media (min-width: 999px) {
12-
1312
.foo {
1413
z-index: 3;
1514
}
16-
1715
.bar {
1816
z-index: 4;
1917
}

test/expected/multiple-queries.css

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1+
.foo {
2+
z-index: 0;
3+
}
4+
15
@media (min-width: 99px) {
2-
.foo {
3-
z-index: 1
4-
}
5-
.bar {
6-
z-index: 2
7-
}
6+
.foo {
7+
z-index: 1;
8+
}
9+
.bar {
10+
z-index: 2;
11+
}
812
}
13+
914
@media (min-width: 999px) {
10-
.baz {
11-
z-index: 3
12-
}
13-
.qux {
14-
z-index: 4
15-
}
15+
.baz {
16+
z-index: 3;
17+
}
18+
.qux {
19+
z-index: 4;
20+
}
1621
}
22+
1723
@media screen and (min-width: 999px) {
18-
.quux {
19-
z-index: 5
20-
}
21-
.corge {
22-
z-index: 6
23-
}
24+
.quux {
25+
z-index: 5;
26+
}
27+
.corge {
28+
z-index: 6;
29+
}
2430
}

test/expected/other-at-rule.css

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
src: local("F");
88
}
99

10-
@media (min-width: 99px){
11-
12-
.foo{
10+
@media (min-width: 99px) {
11+
.foo {
1312
z-index: 1;
1413
}
15-
16-
.bar{
14+
.bar {
1715
z-index: 2;
1816
}
1917
}

test/expected/single-query.css

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111
}
1212

1313
@media (min-width: 999px) {
14-
1514
.foo {
1615
z-index: 4;
1716
}
18-
1917
.bar {
2018
z-index: 5;
2119
}
22-
2320
.baz {
2421
z-index: 6;
2522
}
Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
1+
.foo {
2+
z-index: 0;
3+
}
4+
15
@media (min-width: 16px) {
2-
.foo {
3-
z-index: 1
4-
}
6+
.foo {
7+
z-index: 1;
8+
}
59
}
10+
611
@media (min-width: 1.0625em) {
7-
.foo {
8-
z-index: 2
9-
}
12+
.foo {
13+
z-index: 2;
14+
}
1015
}
16+
1117
@media (min-width: 1.125rem) {
12-
.foo {
13-
z-index: 3
14-
}
18+
.foo {
19+
z-index: 3;
20+
}
1521
}
22+
1623
@media (min-width: 2.29ex) {
17-
.foo {
18-
z-index: 4
19-
}
24+
.foo {
25+
z-index: 4;
26+
}
2027
}
28+
2129
@media (min-width: 2.248ch) {
22-
.foo {
23-
z-index: 5
24-
}
30+
.foo {
31+
z-index: 5;
32+
}
2533
}

0 commit comments

Comments
 (0)