-
Notifications
You must be signed in to change notification settings - Fork 1
/
cupoftea_test.js
79 lines (67 loc) · 1.76 KB
/
cupoftea_test.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
require('./cupoftea');
var assert = require('assert');
var d = function (msg) {
//console.log(msg);
};
spec('cupoftea', function () {
d('top');
var x = 10;
spec('inner_a', function () {
d('inner a');
assert.equal(x, 10);
x = 20;
spec('inner_inner_a', function () {
d('inner inner a');
x++;
assert.equal(x, 21);
});
spec('inner_inner_b', function () {
d('inner inner b');
x++;
x++;
assert.equal(x, 22);
});
spec('inner b (failing)', function () {
d('inner inner b');
x++;
assert.equal(x, 22);
});
});
spec('inner_b', function () {
d('inner b');
assert.equal(x, 10);
x = 20;
});
spec('should not call (failing)', function () {
d('should not call');
process.nextTick(shouldNotCall());
assert.equal(x, 10);
});
spec("should not call and isn't", function () {
d('should not call ---------------');
shouldNotCall();
assert.equal(x, 10);
});
spec('should call', function () {
d('should call');
process.nextTick(shouldCall(function () {
d('stuff');
}));
assert.equal(x, 10);
});
spec('should call but exception thrown (failing)', function () {
d('should call');
process.nextTick(shouldCall(function () {
d('stuff');
throw new Error('exception!');
}));
assert.equal(x, 10);
});
spec("should call but isn't (failing)", function () {
d('should call');
shouldCall(function () {
d('stuff');
});
assert.equal(x, 10);
});
});