'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;
/**
* Constructs a new `Doc` reporter instance.
*
* @public
* @class
* @memberof Mocha.reporters
* @extends Mocha.reporters.Base
* @param {Runner} runner - Instance triggers reporter actions.
* @param {Object} [options] - runner options
*/
function Doc(runner, options) {
Base.call(this, runner, options);
var indents = 2;
function indent() {
return Array(indents).join(' ');
}
runner.on(EVENT_SUITE_BEGIN, function(suite) {
if (suite.root) {
return;
}
++indents;
Base.consoleLog('%s%s
', indent(), utils.escape(suite.title));
Base.consoleLog('%s', indent());
});
runner.on(EVENT_SUITE_END, function(suite) {
if (suite.root) {
return;
}
Base.consoleLog('%s
', indent());
--indents;
Base.consoleLog('%s
%s
%s