|
1 | 1 | 'use strict';
|
2 |
| - |
3 | 2 | const assert = require('assert');
|
4 | 3 | const fs = require('fs');
|
5 | 4 | const path = require('path');
|
6 | 5 | const gutil = require('gulp-util');
|
7 |
| -const mocha = require('../'); |
| 6 | +const mocha = require('..'); |
8 | 7 |
|
9 | 8 | function fixture(name) {
|
10 |
| - let fileName = path.join(__dirname, 'fixtures', name); |
| 9 | + const fileName = path.join(__dirname, 'fixtures', name); |
11 | 10 |
|
12 |
| - return new gutil.File({ |
13 |
| - path: fileName, |
14 |
| - contents: fs.existsSync(fileName) ? fs.readFileSync(fileName) : null |
15 |
| - }); |
| 11 | + return new gutil.File({ |
| 12 | + path: fileName, |
| 13 | + contents: fs.existsSync(fileName) ? fs.readFileSync(fileName) : null |
| 14 | + }); |
16 | 15 | }
|
17 | 16 |
|
18 | 17 | describe('mocha()', () => {
|
19 |
| - it('should run unit test and pass', done => { |
20 |
| - let stream = mocha({suppress: true}); |
| 18 | + it('should run unit test and pass', done => { |
| 19 | + const stream = mocha({suppress: true}); |
21 | 20 |
|
22 |
| - stream.once('result', result => { |
23 |
| - assert(/1 passing/.test(result.stdout)); |
24 |
| - done(); |
25 |
| - }); |
26 |
| - stream.write(fixture('fixture-pass.js')); |
27 |
| - stream.end(); |
28 |
| - }); |
| 21 | + stream.once('_result', result => { |
| 22 | + assert(/1 passing/.test(result.stdout)); |
| 23 | + done(); |
| 24 | + }); |
| 25 | + stream.write(fixture('fixture-pass.js')); |
| 26 | + stream.end(); |
| 27 | + }); |
29 | 28 |
|
30 |
| - it('should run unit test and fail', done => { |
31 |
| - let stream = mocha({suppress: true}); |
| 29 | + it('should run unit test and fail', done => { |
| 30 | + const stream = mocha({suppress: true}); |
32 | 31 |
|
33 |
| - stream.once('error', function (err) { |
34 |
| - assert(/1 failing/.test(err.stdout)); |
35 |
| - done(); |
36 |
| - }); |
37 |
| - stream.write(fixture('fixture-fail.js')); |
38 |
| - stream.end(); |
39 |
| - }); |
| 32 | + stream.once('error', err => { |
| 33 | + assert(/1 failing/.test(err.stdout)); |
| 34 | + done(); |
| 35 | + }); |
| 36 | + stream.write(fixture('fixture-fail.js')); |
| 37 | + stream.end(); |
| 38 | + }); |
40 | 39 |
|
41 |
| - it('should pass async AssertionError to mocha', function (done) { |
42 |
| - let stream = mocha({suppress: true}); |
| 40 | + it('should pass async AssertionError to mocha', done => { |
| 41 | + const stream = mocha({suppress: true}); |
43 | 42 |
|
44 |
| - stream.once('error', function (err) { |
45 |
| - let throws = /throws after timeout/.test(err.stdout); |
46 |
| - let uncaught = /Uncaught AssertionError: false == true/.test(err.stdout); |
| 43 | + stream.once('error', err => { |
| 44 | + const throws = /throws after timeout/.test(err.stdout); |
| 45 | + const uncaught = /Uncaught AssertionError: false == true/.test(err.stdout); |
47 | 46 |
|
48 |
| - assert(throws || uncaught); |
49 |
| - done(); |
50 |
| - }); |
51 |
| - stream.write(fixture('fixture-async.js')); |
52 |
| - stream.end(); |
53 |
| - }); |
| 47 | + assert(throws || uncaught); |
| 48 | + done(); |
| 49 | + }); |
| 50 | + stream.write(fixture('fixture-async.js')); |
| 51 | + stream.end(); |
| 52 | + }); |
54 | 53 |
|
55 |
| - it('should not suppress output', done => { |
56 |
| - let stream = mocha(); |
| 54 | + it('should not suppress output', done => { |
| 55 | + const stream = mocha(); |
57 | 56 |
|
58 |
| - stream.once('result', result => { |
59 |
| - assert(/should pass/.test(result.stdout)); |
60 |
| - done(); |
61 |
| - }); |
62 |
| - stream.write(fixture('fixture-pass.js')); |
63 |
| - stream.end(); |
64 |
| - }); |
| 57 | + stream.once('_result', result => { |
| 58 | + assert(/should pass/.test(result.stdout)); |
| 59 | + done(); |
| 60 | + }); |
| 61 | + stream.write(fixture('fixture-pass.js')); |
| 62 | + stream.end(); |
| 63 | + }); |
65 | 64 | });
|
0 commit comments