1 | 'use strict';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | var Base = require('./base');
|
10 | var inherits = require('../utils').inherits;
|
11 | var constants = require('../runner').constants;
|
12 | var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
|
13 | var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
|
14 | var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;
|
15 | var EVENT_TEST_PENDING = constants.EVENT_TEST_PENDING;
|
16 | var EVENT_RUN_END = constants.EVENT_RUN_END;
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | exports = module.exports = Dot;
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | function Dot(runner, options) {
|
35 | Base.call(this, runner, options);
|
36 |
|
37 | var self = this;
|
38 | var width = (Base.window.width * 0.75) | 0;
|
39 | var n = -1;
|
40 |
|
41 | runner.on(EVENT_RUN_BEGIN, function() {
|
42 | process.stdout.write('\n');
|
43 | });
|
44 |
|
45 | runner.on(EVENT_TEST_PENDING, function() {
|
46 | if (++n % width === 0) {
|
47 | process.stdout.write('\n ');
|
48 | }
|
49 | process.stdout.write(Base.color('pending', Base.symbols.comma));
|
50 | });
|
51 |
|
52 | runner.on(EVENT_TEST_PASS, function(test) {
|
53 | if (++n % width === 0) {
|
54 | process.stdout.write('\n ');
|
55 | }
|
56 | if (test.speed === 'slow') {
|
57 | process.stdout.write(Base.color('bright yellow', Base.symbols.dot));
|
58 | } else {
|
59 | process.stdout.write(Base.color(test.speed, Base.symbols.dot));
|
60 | }
|
61 | });
|
62 |
|
63 | runner.on(EVENT_TEST_FAIL, function() {
|
64 | if (++n % width === 0) {
|
65 | process.stdout.write('\n ');
|
66 | }
|
67 | process.stdout.write(Base.color('fail', Base.symbols.bang));
|
68 | });
|
69 |
|
70 | runner.once(EVENT_RUN_END, function() {
|
71 | process.stdout.write('\n');
|
72 | self.epilogue();
|
73 | });
|
74 | }
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | inherits(Dot, Base);
|
80 |
|
81 | Dot.description = 'dot matrix representation';
|