diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2016-10-31 02:53:46 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-31 02:53:46 +0300 |
commit | 44283a6f19e4f1b2ca96e4ebacab1f2dc8eb42ed (patch) | |
tree | c9c21b56c40f74cdd4c96d6f1f6e11bd0cd597f7 /tests/lib/mocha-3.1.0/test/hook-async.spec.js | |
parent | 395d447052b81ed98b7840df863ec183ed1e285d (diff) | |
parent | 67d67100e4c6b8cd42bae8460477ffb6d0e23988 (diff) |
Merge 3.x-dev into master for 3.0.0-b2 release3.0.0-b2
Diffstat (limited to 'tests/lib/mocha-3.1.0/test/hook-async.spec.js')
-rw-r--r-- | tests/lib/mocha-3.1.0/test/hook-async.spec.js | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/tests/lib/mocha-3.1.0/test/hook-async.spec.js b/tests/lib/mocha-3.1.0/test/hook-async.spec.js new file mode 100644 index 0000000000..ae6e642d24 --- /dev/null +++ b/tests/lib/mocha-3.1.0/test/hook-async.spec.js @@ -0,0 +1,129 @@ +describe('async', function(){ + var calls = []; + + before(function(){ + calls.push('root before all'); + }) + + after(function(){ + calls.push('root after all'); + calls.should.eql([ + 'root before all' + , 'before all' + , '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' + , 'after all' + , 'root after all']); + }) + + beforeEach(function(){ + calls.push('parent before'); + }) + + afterEach(function(){ + calls.push('parent after' ); + }) + + describe('hooks', function(){ + before(function(){ + calls.push('before all'); + }); + + after(function(){ + calls.push('after all'); + }); + + beforeEach(function(done){ + var ctx = this; + process.nextTick(function(){ + calls.push('before'); + if (ctx.currentTest) { + calls.push('before test ' + ctx.currentTest.title); + } + done(); + }) + }) + + it('one', function(done){ + calls.should.eql([ + 'root before all' + , 'before all' + , 'parent before' + , 'before' + , 'before test one']); + calls.push('one'); + process.nextTick(done); + }) + + it('two', function(){ + calls.should.eql([ + 'root before all' + , 'before all' + , '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([ + 'root before all' + , 'before all' + , '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(done){ + var ctx = this; + process.nextTick(function(){ + calls.push('after'); + if (ctx.currentTest) { + calls.push('after test ' + ctx.currentTest.title + ' ' + ctx.currentTest.state); + } + done(); + }) + }) + }) +}) |