Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

added test for cascading Context

TJ Holowaychuk67fb9d101a12
diff --git a/test/acceptance/context.js b/test/acceptance/context.js
index b4f53638..e2af9d5e 100644
--- a/test/acceptance/context.js
+++ b/test/acceptance/context.js
@@ -1,59 +1,26 @@
describe('Context', function(){
- var prev;
-
- before(function(){
- this.age = 2;
- })
-
- after(function(){
- this.age.should.equal(2);
- this.name.should.equal('Tobi');
- this.inspect().should.equal('{\n "age": 2,\n "name": "Tobi"\n}');
- })
-
beforeEach(function(){
- this.name = 'Tobi';
- this.age.should.equal(2);
- })
-
- afterEach(function(){
- this.name.should.equal('Tobi');
- prev = this;
+ this.calls = ['before'];
})
- it('should be maintained between hooks', function(){
- this.name.should.equal('Tobi');
- this.age.should.equal(2);
- })
-
- it('should provide the same object', function(){
- this.should.equal(prev);
- })
-
- describe('when async', function(){
- var prev;
-
- beforeEach(function(done){
- this.name = 'Tobi';
- this.age.should.equal(2);
- done();
+ describe('nested', function(){
+ beforeEach(function(){
+ this.calls.push('before two');
})
- afterEach(function(done){
- this.name.should.equal('Tobi');
- prev = this;
- done();
+ it('should work', function(){
+ this.calls.should.eql(['before', 'before two']);
+ this.calls.push('test');
})
- it('should be maintained between hooks', function(done){
- this.name.should.equal('Tobi');
- done();
+ after(function(){
+ this.calls.should.eql(['before', 'before two', 'test']);
+ this.calls.push('after two');
})
+ })
- it('should provide the same object', function(done){
- this.should.equal(prev);
- done();
- })
+ after(function(){
+ this.calls.should.eql(['before', 'before two', 'test', 'after two']);
})
})
\ No newline at end of file