customizr 2.0.0 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/testing.yml +29 -0
- package/LICENSE +21 -21
- package/README.md +258 -259
- package/bin/customizr +71 -71
- package/build/modernizr-custom.js +6 -6
- package/build/modernizr-exclude.js +438 -73
- package/build/modernizr-package.js +6 -6
- package/build/modernizr-prefixed.js +9 -10
- package/build/modernizr-select.js +11 -12
- package/cache/options.json +14 -1
- package/package.json +62 -60
- package/src/builder.js +118 -118
- package/src/crawler.js +298 -298
- package/src/index.js +64 -64
- package/src/metadata.js +33 -33
- package/src/settings.json +34 -34
- package/src/utils.js +226 -226
- package/test/css/should-ignore.scss +9 -9
- package/test/css/vanilla.css +174 -161
- package/test/js/amd.js +23 -3
- package/test/js/vanilla.js +23 -3
- package/test/pretest.js +133 -133
- package/test/runner.js +17 -17
- package/test/settings/cache-invalidate.json +9 -9
- package/test/settings/custom.json +8 -8
- package/test/settings/exclude.json +14 -14
- package/test/settings/prefixed.json +10 -10
- package/test/settings/select.json +15 -15
- package/test/tests.js +415 -415
package/test/tests.js
CHANGED
|
@@ -1,415 +1,415 @@
|
|
|
1
|
-
/*global describe, before, it, after*/
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
var fs = require("fs");
|
|
6
|
-
var path = require("path");
|
|
7
|
-
var colors = require("colors");
|
|
8
|
-
var cwd = process.cwd();
|
|
9
|
-
|
|
10
|
-
var chai = require('chai');
|
|
11
|
-
var expect = chai.expect;
|
|
12
|
-
var nexpect = require("nexpect");
|
|
13
|
-
|
|
14
|
-
var tests = "
|
|
15
|
-
var testArray = tests.split(", ");
|
|
16
|
-
|
|
17
|
-
var cli = path.join(cwd, "bin", "customizr");
|
|
18
|
-
var settingsPath = path.join(cwd, "test", "settings");
|
|
19
|
-
|
|
20
|
-
var settings = {
|
|
21
|
-
cache: path.join(settingsPath, "cache-invalidate.json"),
|
|
22
|
-
custom: path.join(settingsPath, "custom.json"),
|
|
23
|
-
exclude: path.join(settingsPath, "exclude.json"),
|
|
24
|
-
prefixed: path.join(settingsPath, "prefixed.json"),
|
|
25
|
-
select: path.join(settingsPath, "select.json")
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
describe("customizr", function () {
|
|
29
|
-
var testsLength = testArray.length,
|
|
30
|
-
existingBuild = path.join(cwd, "build", "modernizr-custom.js");
|
|
31
|
-
|
|
32
|
-
it("should find all available tests in project", function (done) {
|
|
33
|
-
process.stdout.write("\n\n");
|
|
34
|
-
|
|
35
|
-
nexpect.spawn(cli, [
|
|
36
|
-
"--config", settings.custom
|
|
37
|
-
], {
|
|
38
|
-
stripColors: true
|
|
39
|
-
})
|
|
40
|
-
.wait("Looking for Modernizr references")
|
|
41
|
-
|
|
42
|
-
.wait(">> " + testsLength + " matches in")
|
|
43
|
-
.expect(">> " + tests)
|
|
44
|
-
|
|
45
|
-
.expect(">> " + testsLength + " matches in")
|
|
46
|
-
.expect(">> " + tests)
|
|
47
|
-
|
|
48
|
-
.expect(">> " + testsLength + " matches in")
|
|
49
|
-
.expect(">> " + tests)
|
|
50
|
-
|
|
51
|
-
.expect(">> Ready to build using these settings:")
|
|
52
|
-
|
|
53
|
-
.wait("Building your customized Modernizr").wait("OK")
|
|
54
|
-
.expect(">> Success! Saved file to build/modernizr-custom.js")
|
|
55
|
-
|
|
56
|
-
.run(function (err) {
|
|
57
|
-
if (!err) {
|
|
58
|
-
done();
|
|
59
|
-
} else {
|
|
60
|
-
throw err;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("should avoid re-building a cached Modernizr build", function (done) {
|
|
66
|
-
process.stdout.write("\n\n");
|
|
67
|
-
|
|
68
|
-
nexpect.spawn(cli, [
|
|
69
|
-
"--config", settings.custom
|
|
70
|
-
], {
|
|
71
|
-
stripColors: true
|
|
72
|
-
})
|
|
73
|
-
.wait("Looking for Modernizr references")
|
|
74
|
-
|
|
75
|
-
.wait(">> " + testsLength + " matches in")
|
|
76
|
-
.expect(">> " + tests)
|
|
77
|
-
|
|
78
|
-
.expect(">> " + testsLength + " matches in")
|
|
79
|
-
.expect(">> " + tests)
|
|
80
|
-
|
|
81
|
-
.expect(">> " + testsLength + " matches in")
|
|
82
|
-
.expect(">> " + tests)
|
|
83
|
-
|
|
84
|
-
.expect("No config or test changes detected")
|
|
85
|
-
.expect(">> The build step has been bypassed. Use `--force` to override.")
|
|
86
|
-
.expect(">> Your current file can be found in build/modernizr-custom.js")
|
|
87
|
-
|
|
88
|
-
.run(function (err) {
|
|
89
|
-
if (!err) {
|
|
90
|
-
done();
|
|
91
|
-
} else {
|
|
92
|
-
throw err;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("should force re-building a cached Modernizr build", function (done) {
|
|
98
|
-
process.stdout.write("\n\n");
|
|
99
|
-
|
|
100
|
-
nexpect.spawn(cli, [
|
|
101
|
-
"--config", settings.custom,
|
|
102
|
-
"--force"
|
|
103
|
-
], {
|
|
104
|
-
stripColors: true
|
|
105
|
-
})
|
|
106
|
-
.wait("Looking for Modernizr references")
|
|
107
|
-
|
|
108
|
-
.wait(">> " + testsLength + " matches in")
|
|
109
|
-
.expect(">> " + tests)
|
|
110
|
-
|
|
111
|
-
.expect(">> " + testsLength + " matches in")
|
|
112
|
-
.expect(">> " + tests)
|
|
113
|
-
|
|
114
|
-
.expect(">> " + testsLength + " matches in")
|
|
115
|
-
.expect(">> " + tests)
|
|
116
|
-
|
|
117
|
-
.expect(">> Ready to build using these settings:")
|
|
118
|
-
|
|
119
|
-
.wait("Building your customized Modernizr").wait("OK")
|
|
120
|
-
.expect(">> Success! Saved file to build/modernizr-custom.js")
|
|
121
|
-
|
|
122
|
-
.run(function (err) {
|
|
123
|
-
if (!err) {
|
|
124
|
-
done();
|
|
125
|
-
} else {
|
|
126
|
-
throw err;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it("should invalidate a cached Modernizr build", function (done) {
|
|
132
|
-
process.stdout.write("\n\n");
|
|
133
|
-
|
|
134
|
-
nexpect.spawn(cli, [
|
|
135
|
-
"--config", settings.cache
|
|
136
|
-
], {
|
|
137
|
-
stripColors: true
|
|
138
|
-
})
|
|
139
|
-
.wait("Looking for Modernizr references")
|
|
140
|
-
|
|
141
|
-
.wait(">> " + testsLength + " matches in")
|
|
142
|
-
.expect(">> " + tests)
|
|
143
|
-
|
|
144
|
-
.expect(">> " + testsLength + " matches in")
|
|
145
|
-
.expect(">> " + tests)
|
|
146
|
-
|
|
147
|
-
.expect(">> " + testsLength + " matches in")
|
|
148
|
-
.expect(">> " + tests)
|
|
149
|
-
|
|
150
|
-
.expect(">> Ready to build using these settings:")
|
|
151
|
-
|
|
152
|
-
.wait("Building your customized Modernizr").wait("OK")
|
|
153
|
-
.expect(">> Success! Saved file to build/modernizr-custom.js")
|
|
154
|
-
|
|
155
|
-
.run(function (err) {
|
|
156
|
-
if (!err) {
|
|
157
|
-
done();
|
|
158
|
-
} else {
|
|
159
|
-
throw err;
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
describe("should include all tests", function () {
|
|
165
|
-
var contents;
|
|
166
|
-
|
|
167
|
-
testArray.forEach(function (test) {
|
|
168
|
-
it(test, function (done) {
|
|
169
|
-
contents = contents || fs.readFileSync(existingBuild, "utf8");
|
|
170
|
-
expect(contents.indexOf(test)).to.not.equal(-1);
|
|
171
|
-
done();
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
describe("custom builds", function () {
|
|
178
|
-
describe("declared tests", function () {
|
|
179
|
-
|
|
180
|
-
it("should only build declared tests", function (done) {
|
|
181
|
-
process.stdout.write("\n\n");
|
|
182
|
-
|
|
183
|
-
nexpect.spawn(cli, [
|
|
184
|
-
"--config", settings.select
|
|
185
|
-
], {
|
|
186
|
-
stripColors: true
|
|
187
|
-
})
|
|
188
|
-
|
|
189
|
-
.wait(">> Explicitly including these tests:")
|
|
190
|
-
.expect(">> cssgrid,cssgridlegacy, siblinggeneral, svg")
|
|
191
|
-
|
|
192
|
-
.expect("Skipping file traversal")
|
|
193
|
-
|
|
194
|
-
.wait("Building your customized Modernizr").wait("OK")
|
|
195
|
-
.expect(">> Success! Saved file to build/modernizr-select.js")
|
|
196
|
-
|
|
197
|
-
.run(function (err) {
|
|
198
|
-
if (!err) {
|
|
199
|
-
done();
|
|
200
|
-
} else {
|
|
201
|
-
throw err;
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
describe("should only contain references to bundled tests", function () {
|
|
207
|
-
|
|
208
|
-
var includedTestArray = [
|
|
209
|
-
"cssgrid",
|
|
210
|
-
"cssgridlegacy",
|
|
211
|
-
"siblinggeneral",
|
|
212
|
-
"svg"
|
|
213
|
-
];
|
|
214
|
-
|
|
215
|
-
var testsLength = includedTestArray.length;
|
|
216
|
-
var includedTests = includedTestArray.join(" ");
|
|
217
|
-
|
|
218
|
-
var contents;
|
|
219
|
-
|
|
220
|
-
includedTestArray.forEach(function (test) {
|
|
221
|
-
it(test, function (done) {
|
|
222
|
-
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-select.js"), "utf8");
|
|
223
|
-
expect(contents.indexOf(test)).to.not.equal(-1);
|
|
224
|
-
done();
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
describe("should not contain these references", function (done) {
|
|
229
|
-
var excludedTestArray = testArray.filter(function (test) {
|
|
230
|
-
return includedTestArray.indexOf(test) === -1;
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
excludedTestArray.forEach(function (test) {
|
|
234
|
-
it(test, function (done) {
|
|
235
|
-
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-select.js"), "utf8");
|
|
236
|
-
|
|
237
|
-
var testPattern = "addTest('" + test.toLowerCase();
|
|
238
|
-
expect(contents.indexOf(testPattern)).to.equal(-1);
|
|
239
|
-
done();
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
describe("excluded tests", function () {
|
|
248
|
-
|
|
249
|
-
it("should build without excluded tests", function (done) {
|
|
250
|
-
process.stdout.write("\n\n");
|
|
251
|
-
|
|
252
|
-
nexpect.spawn(cli, [
|
|
253
|
-
"--config", settings.exclude
|
|
254
|
-
], {
|
|
255
|
-
stripColors: true
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
.wait(">> Explicitly excluding these tests:")
|
|
259
|
-
.expect(">> applicationcache, emoji, notification")
|
|
260
|
-
|
|
261
|
-
.wait("Building your customized Modernizr").wait("OK")
|
|
262
|
-
.expect(">> Success! Saved file to build/modernizr-exclude.js")
|
|
263
|
-
|
|
264
|
-
.run(function (err) {
|
|
265
|
-
if (!err) {
|
|
266
|
-
done();
|
|
267
|
-
} else {
|
|
268
|
-
throw err;
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
describe("should not contain references to excluded tests", function () {
|
|
274
|
-
|
|
275
|
-
var excludedTestArray = [
|
|
276
|
-
"applicationcache",
|
|
277
|
-
"emoji",
|
|
278
|
-
"notification"
|
|
279
|
-
];
|
|
280
|
-
|
|
281
|
-
var testsLength = excludedTestArray.length;
|
|
282
|
-
var excludedTests = excludedTestArray.join(" ");
|
|
283
|
-
|
|
284
|
-
var contents;
|
|
285
|
-
|
|
286
|
-
excludedTestArray.forEach(function (test) {
|
|
287
|
-
it(test, function (done) {
|
|
288
|
-
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-exclude.js"), "utf8");
|
|
289
|
-
expect(contents.indexOf(test)).to.equal(-1);
|
|
290
|
-
done();
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
describe("prefix test", function () {
|
|
298
|
-
|
|
299
|
-
it("should honor the specified prefix", function (done) {
|
|
300
|
-
process.stdout.write("\n\n");
|
|
301
|
-
|
|
302
|
-
nexpect.spawn(cli, [
|
|
303
|
-
"--config", settings.prefixed
|
|
304
|
-
], {
|
|
305
|
-
stripColors: true
|
|
306
|
-
})
|
|
307
|
-
|
|
308
|
-
.wait("Looking for Modernizr references")
|
|
309
|
-
|
|
310
|
-
.expect(">> 3 matches in test/css/vanilla.css")
|
|
311
|
-
.expect(">> cors, input, smil")
|
|
312
|
-
|
|
313
|
-
.wait("Building your customized Modernizr").wait("OK")
|
|
314
|
-
.expect(">> Success! Saved file to build/modernizr-prefixed.js")
|
|
315
|
-
|
|
316
|
-
.run(function (err) {
|
|
317
|
-
if (!err) {
|
|
318
|
-
done();
|
|
319
|
-
} else {
|
|
320
|
-
throw err;
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
|
|
325
|
-
describe("should only contain references to bundled tests", function () {
|
|
326
|
-
|
|
327
|
-
var includedTestArray = [
|
|
328
|
-
"cors",
|
|
329
|
-
"input",
|
|
330
|
-
"smil"
|
|
331
|
-
];
|
|
332
|
-
|
|
333
|
-
var testsLength = includedTestArray.length;
|
|
334
|
-
var includedTests = includedTestArray.join(" ");
|
|
335
|
-
|
|
336
|
-
var contents;
|
|
337
|
-
|
|
338
|
-
includedTestArray.forEach(function (test) {
|
|
339
|
-
it(test, function (done) {
|
|
340
|
-
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-prefixed.js"), "utf8");
|
|
341
|
-
expect(contents.indexOf(test)).to.not.equal(-1);
|
|
342
|
-
done();
|
|
343
|
-
});
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
describe("should not contain these references", function (done) {
|
|
347
|
-
var excludedTestArray = testArray.filter(function (test) {
|
|
348
|
-
return includedTestArray.indexOf(test) === -1;
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
excludedTestArray.forEach(function (test) {
|
|
352
|
-
it(test, function (done) {
|
|
353
|
-
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-prefixed.js"), "utf8");
|
|
354
|
-
|
|
355
|
-
var testPattern = "addTest('" + test.toLowerCase();
|
|
356
|
-
expect(contents.indexOf(testPattern)).to.equal(-1);
|
|
357
|
-
done();
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
});
|
|
362
|
-
|
|
363
|
-
});
|
|
364
|
-
});
|
|
365
|
-
|
|
366
|
-
describe("settings", function() {
|
|
367
|
-
var testsLength = testArray.length,
|
|
368
|
-
existingBuild = path.join(cwd, "build", "modernizr-package.js");
|
|
369
|
-
|
|
370
|
-
it("should honor configs in package.json", function (done) {
|
|
371
|
-
process.stdout.write("\n\n");
|
|
372
|
-
|
|
373
|
-
nexpect.spawn(cli, [
|
|
374
|
-
"--config", 'package.json'
|
|
375
|
-
], {
|
|
376
|
-
stripColors: true
|
|
377
|
-
})
|
|
378
|
-
|
|
379
|
-
.wait("Looking for Modernizr references")
|
|
380
|
-
|
|
381
|
-
.wait(">> " + testsLength + " matches in")
|
|
382
|
-
.expect(">> " + tests)
|
|
383
|
-
|
|
384
|
-
.expect(">> " + testsLength + " matches in")
|
|
385
|
-
.expect(">> " + tests)
|
|
386
|
-
|
|
387
|
-
.expect(">> " + testsLength + " matches in")
|
|
388
|
-
.expect(">> " + tests)
|
|
389
|
-
|
|
390
|
-
.expect(">> Ready to build using these settings:")
|
|
391
|
-
|
|
392
|
-
.wait("Building your customized Modernizr").wait("OK")
|
|
393
|
-
.expect(">> Success! Saved file to build/modernizr-package.js")
|
|
394
|
-
|
|
395
|
-
.run(function (err) {
|
|
396
|
-
if (!err) {
|
|
397
|
-
done();
|
|
398
|
-
} else {
|
|
399
|
-
throw err;
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
describe("should include all tests", function () {
|
|
404
|
-
var contents;
|
|
405
|
-
|
|
406
|
-
testArray.forEach(function (test) {
|
|
407
|
-
it(test, function (done) {
|
|
408
|
-
contents = contents || fs.readFileSync(existingBuild, "utf8");
|
|
409
|
-
expect(contents.indexOf(test)).to.not.equal(-1);
|
|
410
|
-
done();
|
|
411
|
-
});
|
|
412
|
-
});
|
|
413
|
-
});
|
|
414
|
-
});
|
|
415
|
-
});
|
|
1
|
+
/*global describe, before, it, after*/
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
var fs = require("fs");
|
|
6
|
+
var path = require("path");
|
|
7
|
+
var colors = require("colors");
|
|
8
|
+
var cwd = process.cwd();
|
|
9
|
+
|
|
10
|
+
var chai = require('chai');
|
|
11
|
+
var expect = chai.expect;
|
|
12
|
+
var nexpect = require("nexpect");
|
|
13
|
+
|
|
14
|
+
var tests = "adownload, ambientlight, aping, apng, appearance, applicationcache, areaping, arrow, atobbtoa, audio, audioautoplay, audioloop, audiopreload, avif, backdropfilter, backgroundblendmode, backgroundcliptext, backgroundsize, batteryapi, bdi, beacon, bgpositionshorthand, bgpositionxy, bgrepeatround, bgrepeatspace, bgsizecover, blobconstructor, bloburls, blobworkers, borderimage, borderradius, boxdecorationbreak, boxshadow, boxsizing, canvas, canvasblending, canvastext, canvaswinding, capture, checked, classlist, clipboard, connectioneffectivetype, contains, contenteditable, contextmenu, cookies, cors, createelement-attrs, createelementattrs, cryptography, cssall, cssanimations, csscalc, csschunit, csscolumns, cssescape, cssexunit, cssfilters, cssgradients, cssgrid, cssgridlegacy, csshyphens, cssinvalid, cssmask, csspointerevents, csspositionsticky, csspseudoanimations, csspseudotransitions, cssreflections, cssremunit, cssresize, cssscrollbar, csstransforms, csstransforms3d, csstransformslevel2, csstransitions, cssvalid, cssvhunit, cssvmaxunit, cssvminunit, cssvwunit, cubicbezierrange, customelements, customevent, customproperties, customprotocolhandler, dart, datachannel, datalistelem, dataset, datauri, dataview, dataworkers, details, devicemotion, deviceorientation, directory, display-runin, displaytable, documentfragment, ellipsis, emoji, es5, es5array, es5date, es5function, es5object, es5string, es5syntax, es5undefined, es6array, es6class, es6collections, es6math, es6number, es6object, es6string, es6symbol, es7array, es8object, eventlistener, eventsource, exiforientation, fetch, fileinput, filereader, filesystem, flash, flexbox, flexboxlegacy, flexboxtweener, flexgap, flexwrap, focusvisible, focuswithin, fontdisplay, fontface, forcetouch, formattribute, formvalidation, framed, fullscreen, gamepads, generatedcontent, generators, geolocation, getrandomvalues, getusermedia, hairline, hashchange, hidden, hiddenscroll, history, hovermq, hsla, htmlimports, ie8compat, imgcrossorigin, indexeddb, indexeddb2, indexeddbblob, inlinesvg, input, inputformaction, inputformenctype, inputformmethod, inputformnovalidate, inputformtarget, inputsearchevent, inputtypes, intersectionobserver, intl, jpeg2000, jpegxr, json, lastchild, lazyloading, ligatures, localizednumber, localstorage, lowbandwidth, lowbattery, matchmedia, mathml, mediaqueries, mediarecorder, mediasource, messagechannel, meter, microdata, multiplebgs, mutationobserver, notification, nthchild, objectfit, olreversed, oninput, opacity, outputelem, overflowscrolling, pagevisibility, passiveeventlisteners, peerconnection, performance, picture, placeholder, pointerevents, pointerlock, pointermq, postmessage, prefetch, preserve3d, progressbar, promises, proximity, proxy, publickeycredential, queryselector, quotamanagement, regions, requestanimationframe, requestautocomplete, resizeobserver, restdestructuringarray, restdestructuringobject, restparameters, rgba, ruby, sandbox, scriptasync, scriptdefer, scrollsnappoints, scrolltooptions, seamless, serviceworker, sessionstorage, shadowroot, shadowrootlegacy, shapes, sharedworkers, siblinggeneral, sizes, smil, softhyphens, softhyphensfind, speechrecognition, speechsynthesis, spreadarray, spreadobject, srcdoc, srcset, strictmode, stringtemplate, stylescoped, subpixelfont, supports, svg, svgasimg, svgclippaths, svgfilters, svgforeignobject, target, template, templatestrings, textalignlast, textareamaxlength, textdecoder, textdecoration, textencoder, textshadow, texttrackapi, time, todataurljpeg, todataurlpng, todataurlwebp, touchevents, track, transferables, typedarrays, unicode, unicoderange, unknownelements, urlparser, urlsearchparams, userdata, userselect, variablefonts, vibrate, video, videoautoplay, videocrossorigin, videoloop, videopreload, vml, webanimations, webaudio, webgl, webglextensions, webintents, webp, webp-lossless, webpalpha, webpanimation, webplossless, websockets, websocketsbinary, websqldatabase, webworkers, willchange, wrapflow, xdomainrequest, xhr2, xhrresponsetype, xhrresponsetypearraybuffer, xhrresponsetypeblob, xhrresponsetypedocument, xhrresponsetypejson, xhrresponsetypetext";
|
|
15
|
+
var testArray = tests.split(", ");
|
|
16
|
+
|
|
17
|
+
var cli = path.join(cwd, "bin", "customizr");
|
|
18
|
+
var settingsPath = path.join(cwd, "test", "settings");
|
|
19
|
+
|
|
20
|
+
var settings = {
|
|
21
|
+
cache: path.join(settingsPath, "cache-invalidate.json"),
|
|
22
|
+
custom: path.join(settingsPath, "custom.json"),
|
|
23
|
+
exclude: path.join(settingsPath, "exclude.json"),
|
|
24
|
+
prefixed: path.join(settingsPath, "prefixed.json"),
|
|
25
|
+
select: path.join(settingsPath, "select.json")
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
describe("customizr", function () {
|
|
29
|
+
var testsLength = testArray.length,
|
|
30
|
+
existingBuild = path.join(cwd, "build", "modernizr-custom.js");
|
|
31
|
+
|
|
32
|
+
it("should find all available tests in project", function (done) {
|
|
33
|
+
process.stdout.write("\n\n");
|
|
34
|
+
|
|
35
|
+
nexpect.spawn(cli, [
|
|
36
|
+
"--config", settings.custom
|
|
37
|
+
], {
|
|
38
|
+
stripColors: true
|
|
39
|
+
})
|
|
40
|
+
.wait("Looking for Modernizr references")
|
|
41
|
+
|
|
42
|
+
.wait(">> " + testsLength + " matches in")
|
|
43
|
+
.expect(">> " + tests)
|
|
44
|
+
|
|
45
|
+
.expect(">> " + testsLength + " matches in")
|
|
46
|
+
.expect(">> " + tests)
|
|
47
|
+
|
|
48
|
+
.expect(">> " + testsLength + " matches in")
|
|
49
|
+
.expect(">> " + tests)
|
|
50
|
+
|
|
51
|
+
.expect(">> Ready to build using these settings:")
|
|
52
|
+
|
|
53
|
+
.wait("Building your customized Modernizr").wait("OK")
|
|
54
|
+
.expect(">> Success! Saved file to build/modernizr-custom.js")
|
|
55
|
+
|
|
56
|
+
.run(function (err) {
|
|
57
|
+
if (!err) {
|
|
58
|
+
done();
|
|
59
|
+
} else {
|
|
60
|
+
throw err;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("should avoid re-building a cached Modernizr build", function (done) {
|
|
66
|
+
process.stdout.write("\n\n");
|
|
67
|
+
|
|
68
|
+
nexpect.spawn(cli, [
|
|
69
|
+
"--config", settings.custom
|
|
70
|
+
], {
|
|
71
|
+
stripColors: true
|
|
72
|
+
})
|
|
73
|
+
.wait("Looking for Modernizr references")
|
|
74
|
+
|
|
75
|
+
.wait(">> " + testsLength + " matches in")
|
|
76
|
+
.expect(">> " + tests)
|
|
77
|
+
|
|
78
|
+
.expect(">> " + testsLength + " matches in")
|
|
79
|
+
.expect(">> " + tests)
|
|
80
|
+
|
|
81
|
+
.expect(">> " + testsLength + " matches in")
|
|
82
|
+
.expect(">> " + tests)
|
|
83
|
+
|
|
84
|
+
.expect("No config or test changes detected")
|
|
85
|
+
.expect(">> The build step has been bypassed. Use `--force` to override.")
|
|
86
|
+
.expect(">> Your current file can be found in build/modernizr-custom.js")
|
|
87
|
+
|
|
88
|
+
.run(function (err) {
|
|
89
|
+
if (!err) {
|
|
90
|
+
done();
|
|
91
|
+
} else {
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should force re-building a cached Modernizr build", function (done) {
|
|
98
|
+
process.stdout.write("\n\n");
|
|
99
|
+
|
|
100
|
+
nexpect.spawn(cli, [
|
|
101
|
+
"--config", settings.custom,
|
|
102
|
+
"--force"
|
|
103
|
+
], {
|
|
104
|
+
stripColors: true
|
|
105
|
+
})
|
|
106
|
+
.wait("Looking for Modernizr references")
|
|
107
|
+
|
|
108
|
+
.wait(">> " + testsLength + " matches in")
|
|
109
|
+
.expect(">> " + tests)
|
|
110
|
+
|
|
111
|
+
.expect(">> " + testsLength + " matches in")
|
|
112
|
+
.expect(">> " + tests)
|
|
113
|
+
|
|
114
|
+
.expect(">> " + testsLength + " matches in")
|
|
115
|
+
.expect(">> " + tests)
|
|
116
|
+
|
|
117
|
+
.expect(">> Ready to build using these settings:")
|
|
118
|
+
|
|
119
|
+
.wait("Building your customized Modernizr").wait("OK")
|
|
120
|
+
.expect(">> Success! Saved file to build/modernizr-custom.js")
|
|
121
|
+
|
|
122
|
+
.run(function (err) {
|
|
123
|
+
if (!err) {
|
|
124
|
+
done();
|
|
125
|
+
} else {
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("should invalidate a cached Modernizr build", function (done) {
|
|
132
|
+
process.stdout.write("\n\n");
|
|
133
|
+
|
|
134
|
+
nexpect.spawn(cli, [
|
|
135
|
+
"--config", settings.cache
|
|
136
|
+
], {
|
|
137
|
+
stripColors: true
|
|
138
|
+
})
|
|
139
|
+
.wait("Looking for Modernizr references")
|
|
140
|
+
|
|
141
|
+
.wait(">> " + testsLength + " matches in")
|
|
142
|
+
.expect(">> " + tests)
|
|
143
|
+
|
|
144
|
+
.expect(">> " + testsLength + " matches in")
|
|
145
|
+
.expect(">> " + tests)
|
|
146
|
+
|
|
147
|
+
.expect(">> " + testsLength + " matches in")
|
|
148
|
+
.expect(">> " + tests)
|
|
149
|
+
|
|
150
|
+
.expect(">> Ready to build using these settings:")
|
|
151
|
+
|
|
152
|
+
.wait("Building your customized Modernizr").wait("OK")
|
|
153
|
+
.expect(">> Success! Saved file to build/modernizr-custom.js")
|
|
154
|
+
|
|
155
|
+
.run(function (err) {
|
|
156
|
+
if (!err) {
|
|
157
|
+
done();
|
|
158
|
+
} else {
|
|
159
|
+
throw err;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
describe("should include all tests", function () {
|
|
165
|
+
var contents;
|
|
166
|
+
|
|
167
|
+
testArray.forEach(function (test) {
|
|
168
|
+
it(test, function (done) {
|
|
169
|
+
contents = contents || fs.readFileSync(existingBuild, "utf8");
|
|
170
|
+
expect(contents.indexOf(test)).to.not.equal(-1);
|
|
171
|
+
done();
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe("custom builds", function () {
|
|
178
|
+
describe("declared tests", function () {
|
|
179
|
+
|
|
180
|
+
it("should only build declared tests", function (done) {
|
|
181
|
+
process.stdout.write("\n\n");
|
|
182
|
+
|
|
183
|
+
nexpect.spawn(cli, [
|
|
184
|
+
"--config", settings.select
|
|
185
|
+
], {
|
|
186
|
+
stripColors: true
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
.wait(">> Explicitly including these tests:")
|
|
190
|
+
.expect(">> cssgrid,cssgridlegacy, siblinggeneral, svg")
|
|
191
|
+
|
|
192
|
+
.expect("Skipping file traversal")
|
|
193
|
+
|
|
194
|
+
.wait("Building your customized Modernizr").wait("OK")
|
|
195
|
+
.expect(">> Success! Saved file to build/modernizr-select.js")
|
|
196
|
+
|
|
197
|
+
.run(function (err) {
|
|
198
|
+
if (!err) {
|
|
199
|
+
done();
|
|
200
|
+
} else {
|
|
201
|
+
throw err;
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
describe("should only contain references to bundled tests", function () {
|
|
207
|
+
|
|
208
|
+
var includedTestArray = [
|
|
209
|
+
"cssgrid",
|
|
210
|
+
"cssgridlegacy",
|
|
211
|
+
"siblinggeneral",
|
|
212
|
+
"svg"
|
|
213
|
+
];
|
|
214
|
+
|
|
215
|
+
var testsLength = includedTestArray.length;
|
|
216
|
+
var includedTests = includedTestArray.join(" ");
|
|
217
|
+
|
|
218
|
+
var contents;
|
|
219
|
+
|
|
220
|
+
includedTestArray.forEach(function (test) {
|
|
221
|
+
it(test, function (done) {
|
|
222
|
+
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-select.js"), "utf8");
|
|
223
|
+
expect(contents.indexOf(test)).to.not.equal(-1);
|
|
224
|
+
done();
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
describe("should not contain these references", function (done) {
|
|
229
|
+
var excludedTestArray = testArray.filter(function (test) {
|
|
230
|
+
return includedTestArray.indexOf(test) === -1;
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
excludedTestArray.forEach(function (test) {
|
|
234
|
+
it(test, function (done) {
|
|
235
|
+
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-select.js"), "utf8");
|
|
236
|
+
|
|
237
|
+
var testPattern = "addTest('" + test.toLowerCase();
|
|
238
|
+
expect(contents.indexOf(testPattern)).to.equal(-1);
|
|
239
|
+
done();
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe("excluded tests", function () {
|
|
248
|
+
|
|
249
|
+
it("should build without excluded tests", function (done) {
|
|
250
|
+
process.stdout.write("\n\n");
|
|
251
|
+
|
|
252
|
+
nexpect.spawn(cli, [
|
|
253
|
+
"--config", settings.exclude
|
|
254
|
+
], {
|
|
255
|
+
stripColors: true
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
.wait(">> Explicitly excluding these tests:")
|
|
259
|
+
.expect(">> applicationcache, emoji, notification")
|
|
260
|
+
|
|
261
|
+
.wait("Building your customized Modernizr").wait("OK")
|
|
262
|
+
.expect(">> Success! Saved file to build/modernizr-exclude.js")
|
|
263
|
+
|
|
264
|
+
.run(function (err) {
|
|
265
|
+
if (!err) {
|
|
266
|
+
done();
|
|
267
|
+
} else {
|
|
268
|
+
throw err;
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
describe("should not contain references to excluded tests", function () {
|
|
274
|
+
|
|
275
|
+
var excludedTestArray = [
|
|
276
|
+
"applicationcache",
|
|
277
|
+
"emoji",
|
|
278
|
+
"notification"
|
|
279
|
+
];
|
|
280
|
+
|
|
281
|
+
var testsLength = excludedTestArray.length;
|
|
282
|
+
var excludedTests = excludedTestArray.join(" ");
|
|
283
|
+
|
|
284
|
+
var contents;
|
|
285
|
+
|
|
286
|
+
excludedTestArray.forEach(function (test) {
|
|
287
|
+
it(test, function (done) {
|
|
288
|
+
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-exclude.js"), "utf8");
|
|
289
|
+
expect(contents.indexOf(test)).to.equal(-1);
|
|
290
|
+
done();
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
describe("prefix test", function () {
|
|
298
|
+
|
|
299
|
+
it("should honor the specified prefix", function (done) {
|
|
300
|
+
process.stdout.write("\n\n");
|
|
301
|
+
|
|
302
|
+
nexpect.spawn(cli, [
|
|
303
|
+
"--config", settings.prefixed
|
|
304
|
+
], {
|
|
305
|
+
stripColors: true
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
.wait("Looking for Modernizr references")
|
|
309
|
+
|
|
310
|
+
.expect(">> 3 matches in test/css/vanilla.css")
|
|
311
|
+
.expect(">> cors, input, smil")
|
|
312
|
+
|
|
313
|
+
.wait("Building your customized Modernizr").wait("OK")
|
|
314
|
+
.expect(">> Success! Saved file to build/modernizr-prefixed.js")
|
|
315
|
+
|
|
316
|
+
.run(function (err) {
|
|
317
|
+
if (!err) {
|
|
318
|
+
done();
|
|
319
|
+
} else {
|
|
320
|
+
throw err;
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
describe("should only contain references to bundled tests", function () {
|
|
326
|
+
|
|
327
|
+
var includedTestArray = [
|
|
328
|
+
"cors",
|
|
329
|
+
"input",
|
|
330
|
+
"smil"
|
|
331
|
+
];
|
|
332
|
+
|
|
333
|
+
var testsLength = includedTestArray.length;
|
|
334
|
+
var includedTests = includedTestArray.join(" ");
|
|
335
|
+
|
|
336
|
+
var contents;
|
|
337
|
+
|
|
338
|
+
includedTestArray.forEach(function (test) {
|
|
339
|
+
it(test, function (done) {
|
|
340
|
+
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-prefixed.js"), "utf8");
|
|
341
|
+
expect(contents.indexOf(test)).to.not.equal(-1);
|
|
342
|
+
done();
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
describe("should not contain these references", function (done) {
|
|
347
|
+
var excludedTestArray = testArray.filter(function (test) {
|
|
348
|
+
return includedTestArray.indexOf(test) === -1;
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
excludedTestArray.forEach(function (test) {
|
|
352
|
+
it(test, function (done) {
|
|
353
|
+
contents = contents || fs.readFileSync(path.join(cwd, "build", "modernizr-prefixed.js"), "utf8");
|
|
354
|
+
|
|
355
|
+
var testPattern = "addTest('" + test.toLowerCase();
|
|
356
|
+
expect(contents.indexOf(testPattern)).to.equal(-1);
|
|
357
|
+
done();
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
describe("settings", function() {
|
|
367
|
+
var testsLength = testArray.length,
|
|
368
|
+
existingBuild = path.join(cwd, "build", "modernizr-package.js");
|
|
369
|
+
|
|
370
|
+
it("should honor configs in package.json", function (done) {
|
|
371
|
+
process.stdout.write("\n\n");
|
|
372
|
+
|
|
373
|
+
nexpect.spawn(cli, [
|
|
374
|
+
"--config", 'package.json'
|
|
375
|
+
], {
|
|
376
|
+
stripColors: true
|
|
377
|
+
})
|
|
378
|
+
|
|
379
|
+
.wait("Looking for Modernizr references")
|
|
380
|
+
|
|
381
|
+
.wait(">> " + testsLength + " matches in")
|
|
382
|
+
.expect(">> " + tests)
|
|
383
|
+
|
|
384
|
+
.expect(">> " + testsLength + " matches in")
|
|
385
|
+
.expect(">> " + tests)
|
|
386
|
+
|
|
387
|
+
.expect(">> " + testsLength + " matches in")
|
|
388
|
+
.expect(">> " + tests)
|
|
389
|
+
|
|
390
|
+
.expect(">> Ready to build using these settings:")
|
|
391
|
+
|
|
392
|
+
.wait("Building your customized Modernizr").wait("OK")
|
|
393
|
+
.expect(">> Success! Saved file to build/modernizr-package.js")
|
|
394
|
+
|
|
395
|
+
.run(function (err) {
|
|
396
|
+
if (!err) {
|
|
397
|
+
done();
|
|
398
|
+
} else {
|
|
399
|
+
throw err;
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
describe("should include all tests", function () {
|
|
404
|
+
var contents;
|
|
405
|
+
|
|
406
|
+
testArray.forEach(function (test) {
|
|
407
|
+
it(test, function (done) {
|
|
408
|
+
contents = contents || fs.readFileSync(existingBuild, "utf8");
|
|
409
|
+
expect(contents.indexOf(test)).to.not.equal(-1);
|
|
410
|
+
done();
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
});
|
|
415
|
+
});
|