haste-server/node_modules/mocha/lib/reporters/dot.js

62 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2012-02-06 20:09:01 +01:00
/**
* Module dependencies.
*/
var Base = require('./base')
, color = Base.color;
/**
* Expose `Dot`.
*/
exports = module.exports = Dot;
/**
* Initialize a new `Dot` matrix test reporter.
*
* @param {Runner} runner
* @api public
*/
function Dot(runner) {
Base.call(this, runner);
var self = this
, stats = this.stats
, width = Base.window.width * .75 | 0
, n = 0;
runner.on('start', function(){
process.stdout.write('\n ');
});
runner.on('pending', function(test){
process.stdout.write(color('pending', '.'));
});
runner.on('pass', function(test){
if (++n % width == 0) process.stdout.write('\n ');
if ('slow' == test.speed) {
process.stdout.write(color('bright yellow', '.'));
} else {
process.stdout.write(color(test.speed, '.'));
}
});
runner.on('fail', function(test, err){
if (++n % width == 0) process.stdout.write('\n ');
process.stdout.write(color('fail', '.'));
});
runner.on('end', function(){
console.log();
self.epilogue();
});
}
/**
* Inherit from `Base.prototype`.
*/
Dot.prototype.__proto__ = Base.prototype;