Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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.js129
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();
+ })
+ })
+ })
+})