UNPKG

@academyjs/rover

Version:

Rover allows you to learn programming interactively.

69 lines 2.75 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const base_1 = __importDefault(require("./base")); const runner_1 = require("../runner"); const { EVENT_RUN_BEGIN, EVENT_RUN_END, EVENT_SUITE_BEGIN, EVENT_SUITE_END, EVENT_TEST_FAIL, EVENT_TEST_PASS, EVENT_TEST_PENDING, } = runner_1.constants; const { color } = base_1.default; class Spec extends base_1.default { /** * Constructs a new `Spec` reporter instance. */ constructor(runner, options) { super(runner, options); let indents = 0; let n = 0; const indent = () => Array(indents).join(" "); runner.on(EVENT_RUN_BEGIN, () => { base_1.default.consoleLog(); }); runner.on(EVENT_SUITE_BEGIN, (suite) => { ++indents; if (suite.handle) { base_1.default.consoleLog(color("suite", "%s%s"), indent(), `‣ ${suite.handle}\n`); } ++indents; if (suite.title) { base_1.default.consoleLog(color("suite", "%s%s"), indent(), suite.title && `↪ ${suite.title}\n`); } }); runner.on(EVENT_SUITE_END, () => { --indents; --indents; if (indents === 1) { base_1.default.consoleLog(); } }); runner.on(EVENT_TEST_PENDING, (test) => { const format = indent() + color("pending", " - %s"); base_1.default.consoleLog(format, test.title); }); runner.on(EVENT_TEST_PASS, (test) => { let format; if (test.speed === "fast") { format = indent() + color("checkmark", " " + base_1.default.symbols.ok) + color("pass", " %s"); base_1.default.consoleLog(format, test.title && `${test.title}\n`); } else { format = indent() + color("checkmark", " " + base_1.default.symbols.ok) + color("pass", " %s") + color(test.speed, " (%dms)"); base_1.default.consoleLog(format, test.title, test.duration, "\n"); } }); runner.on(EVENT_TEST_FAIL, (test) => { base_1.default.consoleLog(indent() + color("fail", " %d) %s"), ++n, test.title); }); runner.once(EVENT_RUN_END, this.epilogue.bind(this)); } } Spec.description = "hierarchical & verbose [default]"; exports.default = Spec; //# sourceMappingURL=spec.js.map