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

Statements: 97.14% (34 / 35)      Branches: 50% (12 / 24)      Functions: 100% (2 / 2)      Lines: 97.14% (34 / 35)      Ignored: none     

All files » preceptor-reporter/lib/reporter/ » lineSummary.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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88      1             1                 2   2 2   2 2                       2       2   2 2 2   2 2 2           2 2   2 2   2 2   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 LineSummaryReporter
 * @extends AbstractReporter
 * @constructor
 */
var LineSummaryReporter = 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 outcomes,
				failed,
				tree;
 
			this.__super();
 
			tree = this.getContainer().getTree();
			outcomes = this.getContainer().gatherTestOutcomes(tree);
			failed = (outcomes.error + outcomes.failed) > 0;
 
			Eif (this.useColor()) {
				Eif (failed) {
					this.console(undefined, "stop", '\x1B[41m\x1B[37m');
				} else {
					this.console(undefined, "stop", '\x1B[42m');
				}
			}
 
			this.console(undefined, "stop", (failed ? 'Failed' : 'Success') + " (");
			this.console(undefined, "stop", outcomes.tests + " tests");
 
			Eif (outcomes.passed > 0) {
				this.console(undefined, "stop", ", " + outcomes.passed + " passed");
			}
			Eif (outcomes.failed > 0) {
				this.console(undefined, "stop", ", " + outcomes.failed + " failed");
			}
			Eif (outcomes.error > 0) {
				this.console(undefined, "stop", ", " + outcomes.error + " errors");
			}
			Eif (outcomes.skipped > 0) {
				this.console(undefined, "stop", ", " + outcomes.skipped + " skipped");
			}
			Eif (outcomes.incomplete > 0) {
				this.console(undefined, "stop", ", " + outcomes.incomplete + " incomplete");
			}
			Eif (outcomes.undef > 0) {
				this.console(undefined, "stop", ", " + outcomes.undef + " undefined");
			}
			this.console(undefined, "stop", ")");
 
			Eif (this.useColor()) {
				this.console(undefined, "stop", '\x1B[0m');
			}
 
			this.console(undefined, "stop", "\n\n");
		}
	});
 
module.exports = LineSummaryReporter;