dot.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Module dependencies.
  3. */
  4. var Base = require('./base')
  5. , color = Base.color;
  6. /**
  7. * Expose `Dot`.
  8. */
  9. exports = module.exports = Dot;
  10. /**
  11. * Initialize a new `Dot` matrix test reporter.
  12. *
  13. * @param {Runner} runner
  14. * @api public
  15. */
  16. function Dot(runner) {
  17. Base.call(this, runner);
  18. var self = this
  19. , stats = this.stats
  20. , width = Base.window.width * .75 | 0
  21. , n = 0;
  22. runner.on('start', function(){
  23. process.stdout.write('\n ');
  24. });
  25. runner.on('pending', function(test){
  26. process.stdout.write(color('pending', Base.symbols.dot));
  27. });
  28. runner.on('pass', function(test){
  29. if (++n % width == 0) process.stdout.write('\n ');
  30. if ('slow' == test.speed) {
  31. process.stdout.write(color('bright yellow', Base.symbols.dot));
  32. } else {
  33. process.stdout.write(color(test.speed, Base.symbols.dot));
  34. }
  35. });
  36. runner.on('fail', function(test, err){
  37. if (++n % width == 0) process.stdout.write('\n ');
  38. process.stdout.write(color('fail', Base.symbols.dot));
  39. });
  40. runner.on('end', function(){
  41. console.log();
  42. self.epilogue();
  43. });
  44. }
  45. /**
  46. * Inherit from `Base.prototype`.
  47. */
  48. Dot.prototype.__proto__ = Base.prototype;