-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
hooks.spec.js
66 lines (58 loc) · 1.53 KB
/
hooks.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
'use strict';
var assert = require('assert');
var runMocha = require('./helpers').runMocha;
var runJSON = require('./helpers').runMochaJSON;
var splitRegExp = require('./helpers').splitRegExp;
var args = ['--reporter', 'dot'];
describe('hooks', function() {
it('are ran in correct order', function(done) {
runMocha('cascade.fixture.js', args, function(err, res) {
var lines, expected;
if (err) {
done(err);
return;
}
lines = res.output
.split(splitRegExp)
.map(function(line) {
return line.trim();
})
.filter(function(line) {
return line.length;
})
.slice(0, -1);
expected = [
'before one',
'before two',
'before three',
'before each one',
'before each two',
'before each three',
'TEST three',
'after each three',
'after each two',
'after each one',
'after three',
'after two',
'after one'
];
expected.forEach(function(line, i) {
assert.strictEqual(lines[i], line);
});
assert.strictEqual(res.code, 0);
done();
});
});
it('current test title of all hooks', function(done) {
runJSON('current-test-title.fixture.js', [], function(err, res) {
if (err) {
done(err);
return;
}
expect(res, 'to have passed')
.and('to have passed test count', 3)
.and('to have passed test order', 'test1 B', 'test1 C', 'test2 C');
done();
});
});
});