diff options
Diffstat (limited to 'tests/lib/mocha-3.1.2/test/hook-sync.spec.js')
-rw-r--r-- | tests/lib/mocha-3.1.2/test/hook-sync.spec.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/lib/mocha-3.1.2/test/hook-sync.spec.js b/tests/lib/mocha-3.1.2/test/hook-sync.spec.js new file mode 100644 index 0000000000..b1138a6db8 --- /dev/null +++ b/tests/lib/mocha-3.1.2/test/hook-sync.spec.js @@ -0,0 +1,103 @@ +'use strict'; + +describe('serial', function () { + var calls = []; + + beforeEach(function () { + calls.push('parent before'); + }); + + afterEach(function () { + calls.push('parent after'); + }); + + describe('hooks', function () { + beforeEach(function () { + calls.push('before'); + if (this.currentTest) { + calls.push('before test ' + this.currentTest.title); + } + }); + + it('one', function () { + calls.should.eql([ + 'parent before', + 'before', + 'before test one' + ]); + calls.push('one'); + }); + + it('two', function () { + calls.should.eql([ + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two' + ]); + calls.push('two'); + }); + + it('three', function () { + calls.should.eql([ + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two', + 'two', + 'after', + 'after test two passed', + 'parent after', + 'parent before', + 'before', + 'before test three' + ]); + calls.push('three'); + }); + + afterEach(function () { + calls.push('after'); + if (this.currentTest) { + calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state); + } + }); + + after(function () { + calls.should.eql([ + 'parent before', + 'before', + 'before test one', + 'one', + 'after', + 'after test one passed', + 'parent after', + 'parent before', + 'before', + 'before test two', + 'two', + 'after', + 'after test two passed', + 'parent after', + 'parent before', + 'before', + 'before test three', + 'three', + 'after', + 'after test three passed', + 'parent after' + ]); + }); + }); +}); |