This repository has been archived by the owner on Dec 4, 2023. It is now read-only.
forked from mochajs/mocha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot.js
72 lines (61 loc) · 1.36 KB
/
dot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict';
/**
* @module Dot
*/
/**
* Module dependencies.
*/
var Base = require('./base');
var inherits = require('../utils').inherits;
/**
* Expose `Dot`.
*/
exports = module.exports = Dot;
/**
* Initialize a new `Dot` matrix test reporter.
*
* @class
* @memberof Mocha.reporters
* @extends Mocha.reporters.Base
* @public
* @param {Runner} runner
*/
function Dot(runner) {
Base.call(this, runner);
var self = this;
var width = (Base.window.width * 0.75) | 0;
var n = -1;
runner.on('start', function() {
process.stdout.write('\n');
});
runner.on('pending', function() {
if (++n % width === 0) {
process.stdout.write('\n ');
}
process.stdout.write(Base.color('pending', Base.symbols.comma));
});
runner.on('pass', function(test) {
if (++n % width === 0) {
process.stdout.write('\n ');
}
if (test.speed === 'slow') {
process.stdout.write(Base.color('bright yellow', Base.symbols.dot));
} else {
process.stdout.write(Base.color(test.speed, Base.symbols.dot));
}
});
runner.on('fail', function() {
if (++n % width === 0) {
process.stdout.write('\n ');
}
process.stdout.write(Base.color('fail', Base.symbols.bang));
});
runner.once('end', function() {
console.log();
self.epilogue();
});
}
/**
* Inherit from `Base.prototype`.
*/
inherits(Dot, Base);