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 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | exports = module.exports = Dot;
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | function Dot (runner) {
|
24 | Base.call(this, runner);
|
25 |
|
26 | var self = this;
|
27 | var width = Base.window.width * 0.75 | 0;
|
28 | var n = -1;
|
29 |
|
30 | runner.on('start', function () {
|
31 | process.stdout.write('\n');
|
32 | });
|
33 |
|
34 | runner.on('pending', function () {
|
35 | if (++n % width === 0) {
|
36 | process.stdout.write('\n ');
|
37 | }
|
38 | process.stdout.write(color('pending', Base.symbols.comma));
|
39 | });
|
40 |
|
41 | runner.on('pass', function (test) {
|
42 | if (++n % width === 0) {
|
43 | process.stdout.write('\n ');
|
44 | }
|
45 | if (test.speed === 'slow') {
|
46 | process.stdout.write(color('bright yellow', Base.symbols.dot));
|
47 | } else {
|
48 | process.stdout.write(color(test.speed, Base.symbols.dot));
|
49 | }
|
50 | });
|
51 |
|
52 | runner.on('fail', function () {
|
53 | if (++n % width === 0) {
|
54 | process.stdout.write('\n ');
|
55 | }
|
56 | process.stdout.write(color('fail', Base.symbols.bang));
|
57 | });
|
58 |
|
59 | runner.on('end', function () {
|
60 | console.log();
|
61 | self.epilogue();
|
62 | });
|
63 | }
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | inherits(Dot, Base);
|