source: Dev/trunk/node_modules/mocha/lib/reporters/doc.js

Last change on this file was 484, checked in by hendrikvanantwerpen, 11 years ago

Commit node_modules, to make checkouts and builds more deterministic.

File size: 1.1 KB
Line 
1
2/**
3 * Module dependencies.
4 */
5
6var Base = require('./base')
7  , utils = require('../utils');
8
9/**
10 * Expose `Doc`.
11 */
12
13exports = module.exports = Doc;
14
15/**
16 * Initialize a new `Doc` reporter.
17 *
18 * @param {Runner} runner
19 * @api public
20 */
21
22function Doc(runner) {
23  Base.call(this, runner);
24
25  var self = this
26    , stats = this.stats
27    , total = runner.total
28    , indents = 2;
29
30  function indent() {
31    return Array(indents).join('  ');
32  }
33
34  runner.on('suite', function(suite){
35    if (suite.root) return;
36    ++indents;
37    console.log('%s<section class="suite">', indent());
38    ++indents;
39    console.log('%s<h1>%s</h1>', indent(), utils.escape(suite.title));
40    console.log('%s<dl>', indent());
41  });
42
43  runner.on('suite end', function(suite){
44    if (suite.root) return;
45    console.log('%s</dl>', indent());
46    --indents;
47    console.log('%s</section>', indent());
48    --indents;
49  });
50
51  runner.on('pass', function(test){
52    console.log('%s  <dt>%s</dt>', indent(), utils.escape(test.title));
53    var code = utils.escape(utils.clean(test.fn.toString()));
54    console.log('%s  <dd><pre><code>%s</code></pre></dd>', indent(), code);
55  });
56}
Note: See TracBrowser for help on using the repository browser.