Code coverage report for preceptor-reporter/lib/reporter/duration.js

Statements: 83.33% (15 / 18)      Branches: 37.5% (3 / 8)      Functions: 100% (2 / 2)      Lines: 83.33% (15 / 18)      Ignored: none     

All files » preceptor-reporter/lib/reporter/ » duration.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59      1             1                 2   2 2   2 2                       2     2   2   2 2 2             2       1  
// Copyright 2014, Yahoo! Inc.
// Copyrights licensed under the Mit License. See the accompanying LICENSE file for terms.
 
var AbstractReporter = require('../abstractReporter');
 
/**
 * @class DurationReporter
 * @extends AbstractReporter
 * @constructor
 */
var DurationReporter = AbstractReporter.extend(
 
	{
		/**
		 * Initializes the instance
		 *
		 * @method initialize
		 */
		initialize: function () {
			this.__super();
 
			Eif (this.getOptions().progress === undefined) {
				this.getOptions().progress = false;
			}
			Eif (this.getOptions().output === undefined) {
				this.getOptions().output = true;
			}
		},
 
 
		/**
		 * Called when reporting stops
		 *
		 * @method stop
		 */
		stop: function () {
 
			var time,
				tree;
 
			this.__super();
 
			tree = this.getContainer().getTree();
 
			time = tree.duration;
			Eif (time < 1000) {
				time += " milliseconds";
			} else if (time < 120000) {
				time = (time / 1000) + " seconds";
			} else {
				time = (Math.floor(time / 1000) / 60) + " minutes";
			}
 
			this.console(undefined, "stop", "Time: " + time + "\n\n");
		}
	});
 
module.exports = DurationReporter;