Skip to content

Commit

Permalink
Add basic rootHooks test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielstjules committed Dec 11, 2017
1 parent 2722437 commit b55a165
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
76 changes: 76 additions & 0 deletions spec/fixtures/rootHooks.js
@@ -0,0 +1,76 @@
var parallel = require('../../lib/parallel');
var assert = require('assert')

var i = 0;

before('root before', function() {
console.log('root before')
i++;
});

beforeEach('root beforeEach', function() {
console.log('root beforeEach')
i++;
});

afterEach('root afterEach', function() {
console.log('root afterEach')
i++;
});

after('root after', function() {
console.log('root after')
i++;
});

parallel('first suite', function() {
before(function() {
console.log('parallel before')
i++;
});

beforeEach('hook with title', function() {
console.log('parallel beforeEach')
i++;
});

afterEach(function() {
console.log('parallel afterEach')
i++;
});

after(function() {
console.log('parallel after')
i++;
});

it('test', function() {
assert.equal(i, 4)
});
});

parallel('second suite', function() {
before(function() {
console.log('parallel before')
i++;
});

beforeEach('hook with title', function() {
console.log('parallel beforeEach')
i++;
});

afterEach(function() {
console.log('parallel afterEach')
i++;
});

after(function() {
console.log('parallel after')
i++;
});

it('test', function() {
i++;
});
});
11 changes: 11 additions & 0 deletions spec/spec.js
Expand Up @@ -70,6 +70,17 @@ describe('parallel', function() {
});
});

it('correctly supports root hooks', function(done) {
run(fixtures.rootHooks, function(err, stdout, stderr) {
if (err) return done(err);

assert(!stderr.length);
assert(stdout.indexOf('2 passing') !== -1);

done();
});
});

it('supports parent hooks', function(done) {
var hookStr = 'suiteABeforeEach, suiteBBeforeEach, suiteABeforeEach, ' +
'suiteBBeforeEach, childBeforeEach, childBeforeEach';
Expand Down

0 comments on commit b55a165

Please sign in to comment.