-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathspec.js
67 lines (52 loc) · 1.25 KB
/
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
// BDD interface for GT example
// you can confirm this test is typical BDD
// mocha -R spec spec.js
var la = require('lazy-ass');
it('runs a stand alone test', function () {
console.assert('foo' === 'foo');
});
describe('addition', function () {
it('adds integers', function () {
console.assert(2 + 2 === 4);
});
});
var ranAfterEach = false;
describe('before and after', function () {
var setup = 0;
beforeEach(function () {
setup = 1;
});
beforeEach(function () {
setup = 2;
});
afterEach(function () {
ranAfterEach = true;
});
it('ran before each callback', function () {
console.assert(setup === 2, 'both before each blocks ran ' + setup);
setup = 0;
});
it('ran them again', function () {
console.assert(setup === 2, 'both before each blocks ran ' + setup);
});
});
it('ran after each', function () {
console.assert(ranAfterEach, 'ran after each');
});
describe('setting done', function () {
var done = false;
function doIt() { done = true; }
beforeEach(function () {
done = false;
});
it('first spec', function () {
la(!done, '!done initially');
doIt();
la(done);
});
it('second spec', function () {
la(!done, '!done initially');
doIt();
la(done);
});
});