Skip to content

Commit

Permalink
tests
Browse files Browse the repository at this point in the history
  • Loading branch information
juergba committed Aug 13, 2021
1 parent cbc614b commit 6b3ddd3
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 33 deletions.
22 changes: 22 additions & 0 deletions test/integration/options/failZero.spec.js
@@ -0,0 +1,22 @@
'use strict';

var helpers = require('../helpers');
var runMochaJSON = helpers.runMochaJSON;

describe('--fail-zero', function() {
var args = ['--fail-zero', '--grep', 'yyyyyy'];

it('should fail since no tests are encountered', function(done) {
var fixture = '__default__.fixture.js';
runMochaJSON(fixture, args, function(err, res) {
if (err) {
return done(err);
}

expect(res, 'to have passed test count', 0)
.and('to have test count', 0)
.and('to have exit code', 1);
done();
});
});
});
70 changes: 37 additions & 33 deletions test/unit/mocha.spec.js
Expand Up @@ -265,22 +265,18 @@ describe('Mocha', function() {
});

describe('bail()', function() {
describe('when provided no arguments', function() {
it('should set the "bail" flag on the root suite', function() {
mocha.bail();
expect(suite.bail, 'to have a call satisfying', [true]).and(
'was called once'
);
});
it('should set the "bail" flag on the root suite', function() {
mocha.bail();
expect(suite.bail, 'to have a call satisfying', [true]).and(
'was called once'
);
});

describe('when provided a falsy argument', function() {
it('should unset the "bail" flag on the root suite', function() {
mocha.bail(false);
expect(suite.bail, 'to have a call satisfying', [false]).and(
'was called once'
);
});
it('should unset the "bail" flag on the root suite', function() {
mocha.bail(false);
expect(suite.bail, 'to have a call satisfying', [false]).and(
'was called once'
);
});

it('should be chainable', function() {
Expand Down Expand Up @@ -344,25 +340,9 @@ describe('Mocha', function() {
expect(mocha.options, 'to have property', 'diff', true);
});

describe('when provided `false` argument', function() {
it('should set the diff option to false', function() {
mocha.diff(false);
expect(mocha.options, 'to have property', 'diff', false);
});
});
});

describe('dryRun()', function() {
it('should set the dryRun option to true', function() {
mocha.dryRun();
expect(mocha.options, 'to have property', 'dryRun', true);
});

describe('when provided `false` argument', function() {
it('should set the dryRun option to false', function() {
mocha.dryRun(false);
expect(mocha.options, 'to have property', 'dryRun', false);
});
it('should set the diff option to false', function() {
mocha.diff(false);
expect(mocha.options, 'to have property', 'diff', false);
});
});

Expand All @@ -385,6 +365,30 @@ describe('Mocha', function() {
});
});

describe('dryRun()', function() {
it('should set the dryRun option to true', function() {
mocha.dryRun();
expect(mocha.options, 'to have property', 'dryRun', true);
});

it('should set the dryRun option to false', function() {
mocha.dryRun(false);
expect(mocha.options, 'to have property', 'dryRun', false);
});
});

describe('failZero()', function() {
it('should set the failZero option to true', function() {
mocha.failZero();
expect(mocha.options, 'to have property', 'failZero', true);
});

it('should set the failZero option to false', function() {
mocha.failZero(false);
expect(mocha.options, 'to have property', 'failZero', false);
});
});

describe('forbidOnly()', function() {
it('should set the forbidOnly option to true', function() {
mocha.forbidOnly();
Expand Down

0 comments on commit 6b3ddd3

Please sign in to comment.