Skip to content

Commit 339add5

Browse files
committed
add tests for compiler dependency errors
1 parent eda2897 commit 339add5

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

‎test/MultiCompiler.test.js‎

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,57 @@ describe("MultiCompiler", () => {
397397
env.callback.callCount.should.be.exactly(1);
398398
});
399399
});
400+
401+
describe("with missing compiler dependencies", () => {
402+
beforeEach(() => {
403+
setupTwoCompilerEnvironment(env, {
404+
name: "compiler1",
405+
dependencies: ["compiler2"]
406+
}, {
407+
name: "compiler3"
408+
});
409+
env.callback = sinon.spy();
410+
env.options = [{
411+
testWatchOptions: true
412+
}, {
413+
testWatchOptions2: true
414+
}];
415+
env.result = env.myMultiCompiler.watch(env.options, env.callback);
416+
});
417+
418+
it("should call the callback with an error message", () => {
419+
env.compiler1WatchCallbacks.length.should.be.exactly(0);
420+
env.compiler2WatchCallbacks.length.should.be.exactly(0);
421+
env.callback.callCount.should.be.exactly(1);
422+
env.callback.getCall(0).args[0].should.match(/`compiler2` not found/);
423+
});
424+
});
425+
426+
describe("with circular compiler dependencies", () => {
427+
beforeEach(() => {
428+
setupTwoCompilerEnvironment(env, {
429+
name: "compiler1",
430+
dependencies: ["compiler2"]
431+
}, {
432+
name: "compiler2",
433+
dependencies: ["compiler1"]
434+
});
435+
env.callback = sinon.spy();
436+
env.options = [{
437+
testWatchOptions: true
438+
}, {
439+
testWatchOptions2: true
440+
}];
441+
env.result = env.myMultiCompiler.watch(env.options, env.callback);
442+
});
443+
444+
it("should call the callback with an error message", () => {
445+
env.compiler1WatchCallbacks.length.should.be.exactly(0);
446+
env.compiler2WatchCallbacks.length.should.be.exactly(0);
447+
env.callback.callCount.should.be.exactly(1);
448+
env.callback.getCall(0).args[0].should.equal("Circular dependency found in compiler dependencies.");
449+
});
450+
});
400451
});
401452

402453
describe("run", () => {
@@ -489,6 +540,47 @@ describe("MultiCompiler", () => {
489540
env.callback.callCount.should.be.exactly(1);
490541
});
491542
});
543+
544+
describe("with missing compiler dependencies", () => {
545+
beforeEach(() => {
546+
setupTwoCompilerEnvironment(env, {
547+
name: "compiler1",
548+
dependencies: ["compiler2"]
549+
}, {
550+
name: "compiler3"
551+
});
552+
env.callback = sinon.spy();
553+
env.myMultiCompiler.run(env.callback);
554+
});
555+
556+
it("should call the callback with an error message", () => {
557+
env.compiler1RunCallbacks.length.should.be.exactly(0);
558+
env.compiler2RunCallbacks.length.should.be.exactly(0);
559+
env.callback.callCount.should.be.exactly(1);
560+
env.callback.getCall(0).args[0].should.match(/`compiler2` not found/);
561+
});
562+
});
563+
564+
describe("with circular compiler dependencies", () => {
565+
beforeEach(() => {
566+
setupTwoCompilerEnvironment(env, {
567+
name: "compiler1",
568+
dependencies: ["compiler2"]
569+
}, {
570+
name: "compiler2",
571+
dependencies: ["compiler1"]
572+
});
573+
env.callback = sinon.spy();
574+
env.myMultiCompiler.run(env.callback);
575+
});
576+
577+
it("should call the callback with an error message", () => {
578+
env.compiler1RunCallbacks.length.should.be.exactly(0);
579+
env.compiler2RunCallbacks.length.should.be.exactly(0);
580+
env.callback.callCount.should.be.exactly(1);
581+
env.callback.getCall(0).args[0].should.equal("Circular dependency found in compiler dependencies.");
582+
});
583+
});
492584
});
493585

494586
describe("purgeInputFileSystem", () => {

0 commit comments

Comments
 (0)