Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Jan 18, 2020
1 parent 085de5c commit ef383b5
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/unit/runner.spec.js
Expand Up @@ -3,6 +3,7 @@
var path = require('path');
var sinon = require('sinon');
var Mocha = require('../../lib/mocha');
var Pending = require('../../lib/pending');
var Suite = Mocha.Suite;
var Runner = Mocha.Runner;
var Test = Mocha.Test;
Expand Down Expand Up @@ -444,6 +445,13 @@ describe('Runner', function() {
});
});

describe('.runTest(fn)', function() {
it('should return when no tests to run', function() {
runner.test = undefined;
expect(runner.runTest(noop), 'to be undefined');
});
});

describe('allowUncaught', function() {
it('should allow unhandled errors to propagate through', function() {
var newRunner = new Runner(suite);
Expand Down Expand Up @@ -690,6 +698,20 @@ describe('Runner', function() {
sandbox.stub(runner, 'fail');
});

describe('when allow-uncaught is set to true', function() {
it('should propagate error and throw', function() {
var err = new Error('should rethrow err');
runner.allowUncaught = true;
expect(
function() {
runner.uncaught(err);
},
'to throw',
'should rethrow err'
);
});
});

describe('when provided an object argument', function() {
describe('when argument is not an Error', function() {
var err;
Expand All @@ -713,6 +735,13 @@ describe('Runner', function() {
});
});

describe('when argument is a Pending', function() {
it('should ignore argument and return', function() {
var err = new Pending();
expect(runner.uncaught(err), 'to be undefined');
});
});

describe('when argument is an Error', function() {
var err;
beforeEach(function() {
Expand Down

0 comments on commit ef383b5

Please sign in to comment.