pixelnode/node_modules/mocha/lib/reporters/dot.js
2018-04-04 12:31:55 +02:00

67 lines
1.3 KiB
JavaScript

/**
* Module dependencies.
*/
var Base = require('./base');
var inherits = require('../utils').inherits;
var color = Base.color;
/**
* Expose `Dot`.
*/
exports = module.exports = Dot;
/**
* Initialize a new `Dot` matrix test reporter.
*
* @api public
* @param {Runner} runner
*/
function Dot(runner) {
Base.call(this, runner);
var self = this;
var width = Base.window.width * .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(color('pending', Base.symbols.dot));
});
runner.on('pass', function(test) {
if (++n % width === 0) {
process.stdout.write('\n ');
}
if (test.speed === 'slow') {
process.stdout.write(color('bright yellow', Base.symbols.dot));
} else {
process.stdout.write(color(test.speed, Base.symbols.dot));
}
});
runner.on('fail', function() {
if (++n % width === 0) {
process.stdout.write('\n ');
}
process.stdout.write(color('fail', Base.symbols.dot));
});
runner.on('end', function() {
console.log();
self.epilogue();
});
}
/**
* Inherit from `Base.prototype`.
*/
inherits(Dot, Base);