Skip to content

Commit

Permalink
Change tests to accomodate afterEach, fixes #797
Browse files Browse the repository at this point in the history
  • Loading branch information
avaly committed Apr 7, 2013
1 parent 24856d4 commit 7fae7fb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/hook.async.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@ describe('async', function(){
, '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']);
Expand Down Expand Up @@ -81,6 +84,7 @@ describe('async', function(){
, 'before test one'
, 'one'
, 'after'
, 'after test one passed'
, 'parent after'
, 'parent before'
, 'before'
Expand All @@ -97,12 +101,14 @@ describe('async', function(){
, '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'
Expand All @@ -111,8 +117,12 @@ describe('async', function(){
})

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();
})
})
Expand Down
9 changes: 9 additions & 0 deletions test/hook.sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('serial', function(){
, 'before test one'
, 'one'
, 'after'
, 'after test one passed'
, 'parent after'
, 'parent before'
, 'before'
Expand All @@ -47,12 +48,14 @@ describe('serial', function(){
, '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'
Expand All @@ -62,6 +65,9 @@ describe('serial', function(){

afterEach(function(){
calls.push('after');
if (this.currentTest) {
calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state);
}
})

after(function(){
Expand All @@ -71,18 +77,21 @@ describe('serial', function(){
, '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']);
})
})
Expand Down
13 changes: 13 additions & 0 deletions test/hook.sync.nested.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ describe('serial', function(){

afterEach(function(){
calls.push('parent after');
if (this.currentTest) {
calls.push('parent after test ' + this.currentTest.title + ' ' + this.currentTest.state);
}
});

it('foo', function(){
Expand All @@ -27,6 +30,7 @@ describe('serial', function(){
, 'parent before test foo'
, 'foo'
, 'parent after'
, 'parent after test foo passed'
, 'parent before'
, 'parent before test bar']);
})
Expand All @@ -45,9 +49,11 @@ describe('serial', function(){
, 'parent before test foo'
, 'foo'
, 'parent after'
, 'parent after test foo passed'
, 'parent before'
, 'parent before test bar'
, 'parent after'
, 'parent after test bar passed'
, 'parent before'
, 'parent before test one'
, 'before'
Expand All @@ -61,16 +67,20 @@ describe('serial', function(){
, 'parent before test foo'
, 'foo'
, 'parent after'
, 'parent after test foo passed'
, 'parent before'
, 'parent before test bar'
, 'parent after'
, 'parent after test bar passed'
, 'parent before'
, 'parent before test one'
, 'before'
, 'before test one'
, 'one'
, 'after'
, 'after test one passed'
, 'parent after'
, 'parent after test one passed'
, 'parent before'
, 'parent before test two'
, 'before'
Expand All @@ -80,6 +90,9 @@ describe('serial', function(){

afterEach(function(){
calls.push('after');
if (this.currentTest) {
calls.push('after test ' + this.currentTest.title + ' ' + this.currentTest.state);
}
})
})
})
Expand Down

0 comments on commit 7fae7fb

Please sign in to comment.