/**
 * Generates the data received from Mocha's runner under a
 * standard format for the html report
 *
 * @param {Mocha.runner} runner - Mocha's runner
 * @param {generateCb} done
 */
module.exports = function(runner, done) {
  var indentLevel = -1,
      suites = [];

  runner.on('suite', function(suite) {
    suites.push({
      title: suite.title,
      indent: ++indentLevel,
      tests: []
    });
  });

  runner.on('test end', function(test) {
    suites[suites.length - 1].tests.push({
      title: test.title,
      status: test.state === 'passed',
      error: test.err,
      result: test.ctx.result
    });
  });

  runner.on('suite end', function(suite) {
    indentLevel--;
  });

  runner.on('end', function() {
    done(suites);
  });
}

/**
 * The test representing Mocha's "it"
 *
 * @typedef {Object} Test
 * @property {String} title - The description of the test
 * @property {Boolean} status - True => pass and false => fail
 * @property {Object} error - The error in case the test has failed
 * @property {Object} result - The result returned by
 *    [Mugshot]{@link https://github.com/uberVU/mugshot}
 */

/**
 * The suite representing the Mocha's "describe"
 *
 * @typedef {Object} Suite
 * @property {String} title - The description of the suite
 * @property {Array.<Test>} tests - An array with the tests of the suite
 */

/**
 * @callback generateCb
 * @param {Array.<Suite>} suites - The suites from the test files
 */

@@ -494,132 +494,12 @@
 ush(
-%7B%0A      title: test.title,%0A      status: test.state === 'passed',%0A      error: test.err,%0A      result: test.ctx.result%0A    %7D
+test
 );%0A 

put directly Mocha's test object