UNPKG

1.31 kBJavaScriptView Raw
1'use strict';
2
3/**
4 * Module dependencies.
5 */
6
7var Base = require('./base');
8var inherits = require('../utils').inherits;
9var color = Base.color;
10
11/**
12 * Expose `Dot`.
13 */
14
15exports = module.exports = Dot;
16
17/**
18 * Initialize a new `Dot` matrix test reporter.
19 *
20 * @api public
21 * @param {Runner} runner
22 */
23function 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 * Inherit from `Base.prototype`.
67 */
68inherits(Dot, Base);