-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathcss-modules-build-plugin.tests.js
699 lines (584 loc) · 24.7 KB
/
css-modules-build-plugin.tests.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
/* eslint-env node, mocha */
import './test-helpers/global-variables.stub';
import './test-helpers/import-path-helpers.stub';
import chai from 'chai';
// import CssModulesBuildPlugin from './css-modules-build-plugin';
// import { reloadOptions } from './options';
import ImportPathHelpers from './helpers/import-path-helpers';
// import path from 'path';
// import logger from './logger';
import mock from 'mock-require';
import generateFileObject from './test-helpers/generate-file-object';
import { reloadOptions } from './options';
import Fiber from 'fibers';
import Future from 'fibers/future';
import ScssProcessor from './scss-processor';
import CssModulesProcessor from './css-modules-processor';
import { stripIndent } from 'common-tags';
const expect = chai.expect;
mock('meteor/meteor', {
Meteor: {
wrapAsync(fn) {
return function(...args) {
const future = new Future();
fn(...args, function(err, result) {
if (err) {
future.throw(err);
} else {
future.return(result);
}
});
return future.wait();
};
}
}
});
const MockBabel = { compile: (code) => ({ code }) };
mock('meteor/babel-compiler', { Babel: MockBabel });
import { MultiFileCachingCompiler } from './test-helpers/multi-file-caching-compiler';
mock('meteor/caching-compiler', { MultiFileCachingCompiler });
const CssModulesBuildPlugin = require('./css-modules-build-plugin').default;
describe('CssModulesBuildPlugin', function() {
describe('#isRoot', function() {
it('should return true when there are no preprocessors ', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.preprocessors = [];
expect(buildPlugin.isRoot({})).to.be.true;
});
it('should pass the input file argument to preprocessors[]#shouldProcess', function z() {
const buildPlugin = new CssModulesBuildPlugin();
let arg;
const file = {};
buildPlugin.preprocessors = [
{
shouldProcess(file) {
arg = file;
}
},
];
buildPlugin.isRoot(file);
expect(arg).to.equal(file);
});
it('should pass the input file argument to preprocessors[]#isRoot', function z() {
const buildPlugin = new CssModulesBuildPlugin();
let arg;
const file = {};
buildPlugin.preprocessors = [
{
shouldProcess: returnsTrue,
isRoot(file) {
arg = file;
}
},
];
buildPlugin.isRoot(file);
expect(arg).to.equal(file);
});
it('should return true when preprocessors[]#shouldProcess returns false', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.preprocessors = [
{ shouldProcess: returnsFalse },
{ shouldProcess: returnsFalse },
{ shouldProcess: returnsFalse },
];
expect(buildPlugin.isRoot({})).to.be.true;
});
it('should return false when preprocessors[]#shouldProcess returns true and preprocessors[]#isRoot returns false', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.preprocessors = [
{ shouldProcess: returnsTrue, isRoot: returnsFalse },
{ shouldProcess: returnsTrue, isRoot: returnsFalse },
{ shouldProcess: returnsTrue, isRoot: returnsFalse },
];
expect(buildPlugin.isRoot({})).to.be.false;
});
it('should return true when preprocessors[]#shouldProcess returns true and preprocessors[]#isRoot returns true', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.preprocessors = [
{ shouldProcess: returnsTrue, isRoot: returnsFalse },
{ shouldProcess: returnsTrue, isRoot: returnsFalse },
{ shouldProcess: returnsTrue, isRoot: returnsTrue },
];
expect(buildPlugin.isRoot({})).to.be.true;
});
it('should not call preprocessors[]#isRoot if preprocessors[]#shouldProcess returns false', function z() {
const buildPlugin = new CssModulesBuildPlugin();
let wasIsRootCalled = false;
function calledIsRoot() {
wasIsRootCalled = true;
}
buildPlugin.preprocessors = [
{ shouldProcess: returnsFalse, isRoot: calledIsRoot },
{ shouldProcess: returnsFalse, isRoot: calledIsRoot },
{ shouldProcess: returnsFalse, isRoot: calledIsRoot },
];
buildPlugin.isRoot({});
expect(wasIsRootCalled).to.be.false;
});
it('should call preprocessors[]#isRoot if preprocessors[]#shouldProcess returns true', function z() {
const buildPlugin = new CssModulesBuildPlugin();
let isRootCalledCount = 0;
function calledIsRoot() {
isRootCalledCount++;
}
buildPlugin.preprocessors = [
{ shouldProcess: returnsTrue, isRoot: calledIsRoot },
{ shouldProcess: returnsTrue, isRoot: calledIsRoot },
{ shouldProcess: returnsTrue, isRoot: calledIsRoot },
];
buildPlugin.isRoot({});
expect(isRootCalledCount).to.equal(3);
});
it('should call all preprocessors[]#shouldProcess when preprocessors[]#shouldProcess or #isRoot return false', function z() {
const buildPlugin = new CssModulesBuildPlugin();
let callCount = 0;
function incrementCallCount(result = false) {
if (typeof result !== 'boolean') {
result = false;
}
callCount++;
return result;
}
buildPlugin.preprocessors = [
{ shouldProcess: incrementCallCount },
{ shouldProcess: () => incrementCallCount(true), isRoot: () => incrementCallCount(false) },
{ shouldProcess: incrementCallCount },
];
buildPlugin.isRoot({});
expect(callCount).to.equal(4);
});
it('should call all preprocessors[]#isRoot when preprocessors[]#shouldProcess returns true and preprocessors[]#isRoot returns false', function z() {
const buildPlugin = new CssModulesBuildPlugin();
let callCount = 0;
function incrementCallCount() {
callCount++;
return false;
}
buildPlugin.preprocessors = [
{ shouldProcess: returnsTrue, isRoot: incrementCallCount },
{ shouldProcess: returnsTrue, isRoot: incrementCallCount },
{ shouldProcess: returnsTrue, isRoot: incrementCallCount },
];
buildPlugin.isRoot({});
expect(callCount).to.equal(3);
});
it('should stop calling preprocessors[]#shouldProcess when preprocessors[]#isRoot returns true', function z() {
const buildPlugin = new CssModulesBuildPlugin();
const calledIsRootList = [false, false, false];
function calledIsRoot(index, result = false) {
calledIsRootList[index] = true;
return result;
}
buildPlugin.preprocessors = [
{ shouldProcess: returnsTrue, isRoot: () => calledIsRoot(0, false) },
{ shouldProcess: returnsTrue, isRoot: () => calledIsRoot(1, true) },
{ shouldProcess: returnsTrue, isRoot: () => calledIsRoot(2, true) },
];
buildPlugin.isRoot({});
expect(calledIsRootList).to.eql([true, true, false]);
});
});
describe('#compileResultSize', function() {
it('should return the length of the stringified compile result', function z() {
const buildPlugin = new CssModulesBuildPlugin();
expect(buildPlugin.compileResultSize({})).to.equal(2);
expect(buildPlugin.compileResultSize({ test: 1 })).to.equal(10);
});
});
describe('#getCacheKey', function() {
it('should return the inputFile`s source hash combined with the plugin options hash', function z() {
const pluginOptions = reloadOptions();
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.optionsHash = pluginOptions.hash;
const result = `${pluginOptions.hash}...test`;
const sourceHash = 'test';
const file = { getSourceHash: () => sourceHash };
expect(buildPlugin.getCacheKey(file)).to.equal(result);
});
});
describe('#getAbsoluteImportPath', function() {
it('should return the inputFile`s importPath as calculated by ImportPathHelpers', function z() {
const buildPlugin = new CssModulesBuildPlugin();
const file = generateFileObject('./test.css');
const result = `${ImportPathHelpers.basePath.replace(/\\/g, '/')}/test.css`;
expect(buildPlugin.getAbsoluteImportPath(file)).to.equal(result);
});
});
describe('#processFilesForTarget', function() {
it('should store the plugin options hash', function z() {
const pluginOptions = reloadOptions();
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.processFilesForTarget([]);
expect(buildPlugin.optionsHash).to.equal(pluginOptions.hash);
});
it('should pass the files array to MultiFileCachingCompiler#processFilesForTarget', function z(done) {
const filesToProcess = [];
const processFilesForTarget = MultiFileCachingCompiler.prototype.processFilesForTarget;
MultiFileCachingCompiler.prototype.processFilesForTarget = function(files) {
expect(files).to.equal(filesToProcess);
MultiFileCachingCompiler.prototype.processFilesForTarget = processFilesForTarget;
done();
};
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.processFilesForTarget(filesToProcess);
});
it('should reset the filesByName property', function z(done) {
const processFilesForTarget = MultiFileCachingCompiler.prototype.processFilesForTarget;
MultiFileCachingCompiler.prototype.processFilesForTarget = function() {
expect(this.filesByName).to.be.null;
MultiFileCachingCompiler.prototype.processFilesForTarget = processFilesForTarget;
done();
};
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.filesByName = [];
buildPlugin.processFilesForTarget([]);
});
describe('ignorePaths', function() {
it('should remove files from excluded folders', function z(done) {
const originalFiles = [
generateFileObject('./test.css'),
generateFileObject('./yellow.css'),
generateFileObject('./red.css'),
];
const processFilesForTarget = MultiFileCachingCompiler.prototype.processFilesForTarget;
MultiFileCachingCompiler.prototype.processFilesForTarget = function(files) {
expect(files.length).to.equal(2);
expect(files[0]).to.equal(originalFiles[0]);
expect(files[1]).to.equal(originalFiles[2]);
MultiFileCachingCompiler.prototype.processFilesForTarget = processFilesForTarget;
done();
};
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.reloadOptions = () => ({ ...reloadOptions(), ignorePaths: ['yellow'] });
buildPlugin.processFilesForTarget(originalFiles);
});
});
describe('explicitIncludes', function() {
it('should add files from explicitly included folders', function z(done) {
Fiber(function() {
const originalFiles = [
generateFileObject('./test.css'),
generateFileObject('./yellow.css'),
];
const processFilesForTarget = MultiFileCachingCompiler.prototype.processFilesForTarget;
MultiFileCachingCompiler.prototype.processFilesForTarget = function(files) {
expect(files.length).to.equal(4);
expect(files[0]).to.equal(originalFiles[0]);
expect(files[1]).to.equal(originalFiles[1]);
const newFiles = files.slice(2);
newFiles.sort(function(a, b) {
if (a.path < b.path) return -1;
if (a.path > b.path) return 1;
return 0;
});
expect(newFiles[0].path).to.equal('test-helpers/explicit-includes/a.css');
expect(newFiles[1].path).to.equal('test-helpers/explicit-includes/b.css');
MultiFileCachingCompiler.prototype.processFilesForTarget = processFilesForTarget;
done();
};
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.reloadOptions = () => ({
...reloadOptions(),
explicitIncludes: ['./test-helpers/explicit-includes']
});
buildPlugin.processFilesForTarget(originalFiles);
}).run();
});
});
describe('scss preprocessor', function() {
it('should not setup the scss preprocessor when enableSassCompilation is false', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.reloadOptions = () => ({ ...reloadOptions(), enableSassCompilation: false });
buildPlugin.processFilesForTarget([]);
expect(buildPlugin.preprocessors.length).to.equal(0);
});
it('should not setup the scss preprocessor when enableSassCompilation is falsy', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.reloadOptions = () => ({ ...reloadOptions(), enableSassCompilation: null });
buildPlugin.processFilesForTarget([]);
expect(buildPlugin.preprocessors.length).to.equal(0);
});
it('should setup the scss preprocessor when enableSassCompilation is true', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.reloadOptions = () => ({ ...reloadOptions(), enableSassCompilation: true });
buildPlugin.processFilesForTarget([]);
expect(buildPlugin.preprocessors[0]).to.be.an.instanceOf(ScssProcessor);
});
it('should setup the scss preprocessor when enableSassCompilation is truthy', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.reloadOptions = () => ({ ...reloadOptions(), enableSassCompilation: [] });
buildPlugin.processFilesForTarget([]);
expect(buildPlugin.preprocessors[0]).to.be.an.instanceOf(ScssProcessor);
});
});
describe('css modules processor', function() {
it('should set up the cssModulesProcessor', function z() {
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.processFilesForTarget([]);
expect(buildPlugin.cssModulesProcessor).to.be.an.instanceOf(CssModulesProcessor);
});
});
});
describe('#compileOneFile', function() {
describe('.compileResult', function() {
describe('stylesheet', function() {
it('should return stylesheet code for web architecture', function z(done) {
Fiber(function() {
const file = generateFileObject('./test.css', '.test { color: red; }');
const cssModulesProcessor = { process: noop };
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
const result = buildPlugin.compileOneFile(file);
expect(result.compileResult.stylesheet).to.equal('.test { color: red; }');
done();
}).run();
});
it('should not return stylesheet code for lazy-loaded files', function z(done) {
Fiber(function() {
const file = generateFileObject('./imports/test.css', '.test { color: red; }');
const cssModulesProcessor = { process: noop };
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
const result = buildPlugin.compileOneFile(file);
expect('stylesheet' in result.compileResult).to.be.false;
done();
}).run();
});
it('should not return stylesheet code for server architecture', function z(done) {
Fiber(function() {
const file = generateFileObject('./test.css', '.test { color: red; }');
file.arch = 'server';
const cssModulesProcessor = { process: noop };
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
const result = buildPlugin.compileOneFile(file);
expect('stylesheet' in result.compileResult).to.be.false;
done();
}).run();
});
});
describe('javascript', function() {
it('should include the javascript class mappings', function z(done) {
Fiber(function() {
const file = generateFileObject('./test.css', '.test { color: red; }');
file.tokens = { 'test': 'TEST' };
const cssModulesProcessor = { process: noop };
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
const result = buildPlugin.compileOneFile(file);
expect(result.compileResult.javascript).to.equal(stripIndent`
const styles = {"test":"TEST"};
export { styles as default, styles };
`);
done();
}).run();
});
it('should include module imports for imported files', function z(done) {
Fiber(function() {
const file = generateFileObject('./test.css', '.test { color: red; }');
file.imports = ['./a.css', './b/b.css'];
const cssModulesProcessor = { process: noop };
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
const result = buildPlugin.compileOneFile(file);
expect(result.compileResult.javascript).to.equal(stripIndent`
import './a.css';
import './b/b.css';
`);
done();
}).run();
});
it('should include the stylesheet for lazy-loaded files', function z(done) {
Fiber(function() {
const file = generateFileObject('./imports/test.css', '.test { color: red; }');
const cssModulesProcessor = { process: noop };
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
const result = buildPlugin.compileOneFile(file);
expect(result.compileResult.javascript).to.equal(stripIndent`
import modules from 'meteor/modules';
modules.addStyles(".test { color: red; }");
`);
done();
}).run();
});
it('should include the module imports, stylesheet, and class mapping when applicable', function z(done) {
Fiber(function() {
const file = generateFileObject('./imports/test.css', '.test { color: red; }');
file.tokens = { 'test': 'TEST' };
file.imports = ['./a.css', './b/b.css'];
const cssModulesProcessor = { process: noop };
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
const result = buildPlugin.compileOneFile(file);
expect(result.compileResult.javascript).to.equal(stripIndent`
import './a.css';
import './b/b.css';
import modules from 'meteor/modules';
modules.addStyles(".test { color: red; }");
const styles = {"test":"TEST"};
export { styles as default, styles };
`
);
done();
}).run();
});
});
});
describe('.referencedImportPaths', function() {
it('should return the referencedImportPaths', function z(done) {
Fiber(function() {
const file = generateFileObject('./test.css', '.test { color: red; }');
file.referencedImportPaths = [];
const cssModulesProcessor = { process: noop };
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
const result = buildPlugin.compileOneFile(file);
expect(result.referencedImportPaths).to.equal(file.referencedImportPaths);
done();
}).run();
});
});
describe('css modules processor', function() {
it('should process the files through the css modules processor', function z(done) {
Fiber(function() {
const file = generateFileObject('./test.css');
const cssModulesProcessor = {
process(fileArg) {
expect(fileArg).to.equal(file);
done();
}
};
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [];
buildPlugin.filesByName = new Map();
buildPlugin.compileOneFile(file);
}).run();
});
});
describe('preprocessor', function() {
it('should run the files through any matching preprocessors', function z(done) {
Fiber(function() {
const file = generateFileObject('./test.css');
let error;
let numberOfPreprocessorsCalled = 0;
const notMatchingPreprocessor1 = {
shouldProcess: returnsFalse,
isRoot: returnsFalse,
process: shouldNotBeCalled,
};
const notMatchingPreprocessor2 = {
shouldProcess: returnsFalse,
isRoot: returnsFalse,
process: shouldNotBeCalled,
};
const matchingPreprocessor1 = {
shouldProcess: returnsTrue,
isRoot: returnsTrue,
process(fileArg) {
expect(fileArg).to.equal(file);
numberOfPreprocessorsCalled++;
}
};
const matchingPreprocessor2 = {
shouldProcess: returnsTrue,
isRoot: returnsTrue,
process(fileArg) {
expect(fileArg).to.equal(file);
numberOfPreprocessorsCalled++;
}
};
const cssModulesProcessor = {
process() {
expect(numberOfPreprocessorsCalled).to.equal(2);
done(error);
}
};
const buildPlugin = new CssModulesBuildPlugin();
buildPlugin.cssModulesProcessor = cssModulesProcessor;
buildPlugin.preprocessors = [
notMatchingPreprocessor1,
matchingPreprocessor1,
matchingPreprocessor2,
notMatchingPreprocessor2,
];
buildPlugin.filesByName = new Map();
buildPlugin.compileOneFile(file);
}).run();
});
});
});
describe('#addCompileResult', function() {
it('should add the stylesheet result', function z() {
const buildPlugin = new CssModulesBuildPlugin();
let wasCalled = false;
const compileResult = {
stylesheet: {},
filePath: './test.css',
sourceMap: { test: true }
};
const file = {
addStylesheet(stylesheet) {
wasCalled = true;
expect(stylesheet.data).to.equal(compileResult.stylesheet);
expect(stylesheet.path).to.equal('./test.css.css');
expect(stylesheet.sourcePath).to.equal('./test.css.css');
expect(stylesheet.sourceMap).to.equal(JSON.stringify(compileResult.sourceMap));
expect(stylesheet.lazy).to.be.false;
}
};
buildPlugin.addCompileResult(file, compileResult);
expect(wasCalled).to.be.true;
});
it('should add the javascript result', function z() {
const buildPlugin = new CssModulesBuildPlugin();
let wasCalled = false;
const compileResult = {
javascript: {},
filePath: './test.css',
sourceMap: { test: true },
isLazy: {},
};
const file = {
addJavaScript(javascript) {
wasCalled = true;
expect(javascript.data).to.equal(compileResult.javascript);
expect(javascript.path).to.equal('./test.css.js');
expect(javascript.sourcePath).to.equal('./test.css');
expect(javascript.lazy).to.equal(compileResult.isLazy);
expect(javascript.bare).to.be.false;
}
};
buildPlugin.addCompileResult(file, compileResult);
expect(wasCalled).to.be.true;
});
});
});
function noop() {
}
function returnsFalse() {
return false;
}
function returnsTrue() {
return true;
}
function shouldNotBeCalled() {
throw new Error('This function should not called in the tested execution path!');
}