-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
suite.spec.js
95 lines (89 loc) · 2.42 KB
/
suite.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
94
95
'use strict';
var run = require('./helpers').runMocha;
var args = [];
describe('suite w/no callback', function () {
it('should throw a helpful error message when a callback for suite is not supplied', function (done) {
run(
'suite/suite-no-callback.fixture.js',
args,
function (err, res) {
if (err) {
return done(err);
}
expect(
res.output,
'to match',
/no callback was supplied. Supply a callback/
);
done();
},
{stdio: 'pipe'}
);
});
});
describe('skipped suite w/no callback', function () {
it('should not throw an error when a callback for skipped suite is not supplied', function (done) {
run(
'suite/suite-skipped-no-callback.fixture.js',
args,
function (err, res) {
if (err) {
return done(err);
}
var pattern = /TypeError/g;
var result = res.output.match(pattern) || [];
expect(result, 'to have length', 0);
done();
}
);
});
});
describe('skipped suite w/ callback', function () {
it('should not throw an error when a callback for skipped suite is supplied', function (done) {
run('suite/suite-skipped-callback.fixture.js', args, function (err, res) {
if (err) {
return done(err);
}
var pattern = /TypeError/g;
var result = res.output.match(pattern) || [];
expect(result, 'to have length', 0);
done();
});
});
});
describe('suite returning a value', function () {
it('should not give a deprecation warning for suite callback returning a value', function (done) {
run(
'suite/suite-returning-value.fixture.js',
args,
function (err, res) {
if (err) {
return done(err);
}
expect(res, 'not to contain output', /Suites ignore return values/);
done();
},
{stdio: 'pipe'}
);
});
});
describe('suite w/async callback', function () {
it('should print a helpful deprecation message when a callback for suite is async', function (done) {
run(
'suite/suite-async-callback.fixture.js',
args,
function (err, res) {
if (err) {
return done(err);
}
expect(
res.output,
'to match',
/Asynchronous suites are not supported, use a synchronous callback instead./
);
done();
},
{stdio: 'pipe'}
);
});
});