'use strict';
/**
* @module Doc
*/
/**
* Module dependencies.
*/
var Base = require('./base');
var utils = require('../utils');
var constants = require('../runner').constants;
var EVENT_TEST_PASS = constants.EVENT_TEST_PASS;
var EVENT_TEST_FAIL = constants.EVENT_TEST_FAIL;
var EVENT_SUITE_BEGIN = constants.EVENT_SUITE_BEGIN;
var EVENT_SUITE_END = constants.EVENT_SUITE_END;
/**
* Expose `Doc`.
*/
exports = module.exports = Doc;
/**
* Initialize a new `Doc` reporter.
*
* @class
* @memberof Mocha.reporters
* @extends {Base}
* @public
* @param {Runner} runner
*/
function Doc(runner) {
Base.call(this, runner);
var indents = 2;
function indent() {
return Array(indents).join(' ');
}
runner.on(EVENT_SUITE_BEGIN, function(suite) {
if (suite.root) {
return;
}
++indents;
console.log('%s%s
', indent(), utils.escape(suite.title));
console.log('%s', indent());
});
runner.on(EVENT_SUITE_END, function(suite) {
if (suite.root) {
return;
}
console.log('%s
', indent());
--indents;
console.log('%s
%s
%s