From 42280e893d259ebebd9b33d33c874358ea9e823f Mon Sep 17 00:00:00 2001 From: Josh Soref Date: Mon, 4 Sep 2017 04:15:35 +0000 Subject: [PATCH] Fix broken nextTick test --- test/unit/throw.spec.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/unit/throw.spec.js b/test/unit/throw.spec.js index 68e8cd2c1d..cdcfb50637 100644 --- a/test/unit/throw.spec.js +++ b/test/unit/throw.spec.js @@ -45,16 +45,21 @@ describe('a test that throws', function () { it('should not pass if throwing async and test is async', function (done) { var test = new Test('im async and throw undefined async', function (done2) { - process.nexTick(function () { + process.nextTick(function () { throw undefined; }); }); suite.addTest(test); runner = new Runner(suite); + var uncaught = Runner.prototype.uncaught; + Runner.prototype.uncaught = function () { + Runner.prototype.uncaught = uncaught; + done(); + }; runner.on('end', function () { expect(runner.failures).to.equal(1); expect(test.state).to.equal('failed'); - done(); + expect(runner.uncaught).toBeCalled(); }); runner.run(); }); @@ -91,16 +96,21 @@ describe('a test that throws', function () { it('should not pass if throwing async and test is async', function (done) { var test = new Test('im async and throw null async', function (done2) { - process.nexTick(function () { + process.nextTick(function () { throw null; }); }); suite.addTest(test); runner = new Runner(suite); + var uncaught = Runner.prototype.uncaught; + Runner.prototype.uncaught = function () { + Runner.prototype.uncaught = uncaught; + done(); + }; runner.on('end', function () { expect(runner.failures).to.equal(1); expect(test.state).to.equal('failed'); - done(); + expect(runner.uncaught).toBeCalled(); }); runner.run(); });