source: Dev/trunk/node_modules/mocha/lib/reporters/html-cov.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: 876 bytes
Line 
1
2/**
3 * Module dependencies.
4 */
5
6var JSONCov = require('./json-cov')
7  , fs = require('fs');
8
9/**
10 * Expose `HTMLCov`.
11 */
12
13exports = module.exports = HTMLCov;
14
15/**
16 * Initialize a new `JsCoverage` reporter.
17 *
18 * @param {Runner} runner
19 * @api public
20 */
21
22function HTMLCov(runner) {
23  var jade = require('jade')
24    , file = __dirname + '/templates/coverage.jade'
25    , str = fs.readFileSync(file, 'utf8')
26    , fn = jade.compile(str, { filename: file })
27    , self = this;
28
29  JSONCov.call(this, runner, false);
30
31  runner.on('end', function(){
32    process.stdout.write(fn({
33        cov: self.cov
34      , coverageClass: coverageClass
35    }));
36  });
37}
38
39/**
40 * Return coverage class for `n`.
41 *
42 * @return {String}
43 * @api private
44 */
45
46function coverageClass(n) {
47  if (n >= 75) return 'high';
48  if (n >= 50) return 'medium';
49  if (n >= 25) return 'low';
50  return 'terrible';
51}
Note: See TracBrowser for help on using the repository browser.