forked from mochajs/mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhook.async.js
107 lines (95 loc) · 2 KB
/
hook.async.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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'
, 'one'
, 'after'
, 'parent after'
, 'parent before'
, 'before'
, 'two'
, 'after'
, 'parent after'
, 'parent before'
, 'before'
, 'three'
, 'after'
, '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){
process.nextTick(function(){
calls.push('before');
done();
})
})
it('one', function(done){
calls.should.eql([
'root before all'
, 'before all'
, 'parent before'
, 'before']);
calls.push('one');
process.nextTick(done);
})
it('two', function(){
calls.should.eql([
'root before all'
, 'before all'
, 'parent before'
, 'before'
, 'one'
, 'after'
, 'parent after'
, 'parent before'
, 'before']);
calls.push('two');
})
it('three', function(){
calls.should.eql([
'root before all'
, 'before all'
, 'parent before'
, 'before'
, 'one'
, 'after'
, 'parent after'
, 'parent before'
, 'before'
, 'two'
, 'after'
, 'parent after'
, 'parent before'
, 'before']);
calls.push('three');
})
afterEach(function(done){
process.nextTick(function(){
calls.push('after');
done();
})
})
})
})