-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
62 lines (50 loc) · 1.28 KB
/
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
'use strict';
var assert = require('assert');
var gutil = require('gulp-util');
var mocha = require('./index');
var out = process.stdout.write.bind(process.stdout);
var err = process.stderr.write.bind(process.stderr);
it('should run unit test and pass', function (cb) {
var stream = mocha();
process.stdout.write = function (str) {
if (/1 passing/.test(str)) {
assert(true);
process.stdout.write = out;
cb();
}
};
stream.write(new gutil.File({path: 'fixture-pass.js'}));
stream.end();
});
it('should run unit test with yield and pass', function (cb) {
var stream = mocha();
process.stdout.write = function (str) {
if (/1 passing/.test(str)) {
assert(true);
process.stdout.write = out;
cb();
}
};
stream.write(new gutil.File({path: 'fixture-pass-generator.js'}));
stream.end();
});
it('should run unit test and fail', function (cb) {
var stream = mocha();
process.stderr.write = function (str) {
if (/1 failing/.test(str)) {
assert(true);
process.stderr.write = err;
cb();
}
};
stream.on('error', function () {});
stream.write(new gutil.File({path: 'fixture-fail.js'}));
stream.end();
});
it('should call the callback for the flush method', function (cb) {
var stream = mocha();
stream._flush(function () {
assert(true);
cb();
});
});