1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | var Base = require('./base');
|
8 | var inherits = require('../utils').inherits;
|
9 | var color = Base.color;
|
10 | var cursor = Base.cursor;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | exports = module.exports = List;
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function List (runner) {
|
25 | Base.call(this, runner);
|
26 |
|
27 | var self = this;
|
28 | var n = 0;
|
29 |
|
30 | runner.on('start', function () {
|
31 | console.log();
|
32 | });
|
33 |
|
34 | runner.on('test', function (test) {
|
35 | process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
|
36 | });
|
37 |
|
38 | runner.on('pending', function (test) {
|
39 | var fmt = color('checkmark', ' -') +
|
40 | color('pending', ' %s');
|
41 | console.log(fmt, test.fullTitle());
|
42 | });
|
43 |
|
44 | runner.on('pass', function (test) {
|
45 | var fmt = color('checkmark', ' ' + Base.symbols.ok) +
|
46 | color('pass', ' %s: ') +
|
47 | color(test.speed, '%dms');
|
48 | cursor.CR();
|
49 | console.log(fmt, test.fullTitle(), test.duration);
|
50 | });
|
51 |
|
52 | runner.on('fail', function (test) {
|
53 | cursor.CR();
|
54 | console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
|
55 | });
|
56 |
|
57 | runner.on('end', self.epilogue.bind(self));
|
58 | }
|
59 |
|
60 |
|
61 |
|
62 |
|
63 | inherits(List, Base);
|