forked from mochajs/mocha
/
context.spec.js
93 lines (76 loc) · 2.36 KB
/
context.spec.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
'use strict';
describe('Context', function () {
beforeEach(function () {
this.calls = ['before'];
});
describe('nested', function () {
beforeEach(function () {
this.calls.push('before two');
});
it('should work', function () {
expect(this.calls).to.eql(['before', 'before two']);
this.calls.push('test');
});
after(function () {
expect(this.calls).to.eql(['before', 'before two', 'test']);
this.calls.push('after two');
});
});
after(function () {
expect(this.calls).to.eql(['before', 'before two', 'test', 'after two']);
});
});
describe('Context Siblings', function () {
beforeEach(function () {
this.calls = ['before'];
});
describe('sequestered sibling', function () {
beforeEach(function () {
this.calls.push('before two');
this.hiddenFromSibling = 'This should be hidden';
});
it('should work', function () {
expect(this.hiddenFromSibling).to.eql('This should be hidden');
});
});
describe('sibling verifiction', function () {
beforeEach(function () {
this.calls.push('before sibling');
});
it('should not have value set within a sibling describe', function () {
expect('This should be hidden').not.to.eql(this.hiddenFromSibling);
this.visibleFromTestSibling = 'Visible from test sibling';
});
it('should allow test siblings to modify shared context', function () {
expect('Visible from test sibling').to.eql(this.visibleFromTestSibling);
});
it('should have reset this.calls before describe', function () {
expect(this.calls).to.eql(['before', 'before sibling']);
});
});
after(function () {
expect(this.calls).to.eql(['before', 'before sibling']);
});
});
describe('methods', function () {
describe('timeout()', function () {
it('should return the timeout', function () {
expect(this.timeout()).to.equal(200);
});
});
describe('slow()', function () {
it('should return the slow', function () {
expect(this.slow()).to.equal(75);
});
});
describe('enableTimeouts()', function () {
it('should return the enableTimeouts', function () {
expect(this.enableTimeouts()).to.equal(true);
});
});
describe('retries', function () {
it('should return the number of retries', function () {
expect(this.retries()).to.equal(-1);
});
});
});