| 1 | "use strict"; |
| 2 | |
| 3 | /** |
| 4 | * @typedef {import('../runner.js')} Runner |
| 5 | */ |
| 6 | |
| 7 | /** |
| 8 | * @module Progress |
| 9 | */ |
| 10 | /** |
| 11 | * Module dependencies. |
| 12 | */ |
| 13 | |
| 14 | var Basescip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Base. = require("./base"scip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/); |
| 15 | var constantsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/constants. = require("../runner"scip-typescript npm mocha 11.7.7 lib/`runner.js`/).constants; |
| 16 | var EVENT_RUN_BEGINscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/EVENT_RUN_BEGIN. = constants.EVENT_RUN_BEGIN; |
| 17 | var EVENT_TEST_ENDscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/EVENT_TEST_END. = constants.EVENT_TEST_END; |
| 18 | var EVENT_RUN_ENDscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/EVENT_RUN_END. = constants.EVENT_RUN_END; |
| 19 | var inheritsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/inherits. = require("../utils"scip-typescript npm mocha 11.7.7 lib/`utils.js`/).inherits; |
| 20 | var colorscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/color. = Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..color; |
| 21 | var cursorscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/cursor. = Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..cursor; |
| 22 | |
| 23 | /** |
| 24 | * Expose `Progress`. |
| 25 | */ |
| 26 | |
| 27 | exportsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/ = module.exports = Progressscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().; |
| 28 | |
| 29 | /** |
| 30 | * General progress bar color. |
| 31 | */ |
| 32 | |
| 33 | Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..colors.progress = 90; |
| 34 | |
| 35 | /** |
| 36 | * Constructs a new `Progress` reporter instance. |
| 37 | * |
| 38 | * @public |
| 39 | * @class |
| 40 | * @memberof Mocha.reporters |
| 41 | * @extends Mocha.reporters.Base |
| 42 | * @param {Runner} runner - Instance triggers reporter actions. |
| 43 | * @param {Object} [options] - runner options |
| 44 | */ |
| 45 | function Progressscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(runnerscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(runner), optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options)) { |
| 46 | Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..callscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Function#call().(this, runnerscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(runner), optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options)); |
| 47 | |
| 48 | var self = this; |
| 49 | var width = (Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..window.widthscip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/width0: * 0.5) | 0; |
| 50 | var total = runnerscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(runner).total; |
| 51 | var complete = 0; |
| 52 | var lastN = -1; |
| 53 | |
| 54 | // default chars |
| 55 | optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options) = optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options) || {}; |
| 56 | var reporterOptions = optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).reporterOptions || {}; |
| 57 | |
| 58 | optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).open = reporterOptions.open || "["; |
| 59 | optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).complete = reporterOptions.complete || "▬"; |
| 60 | optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).incomplete = reporterOptions.incomplete || Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..symbols.dotscip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/dot0:; |
| 61 | optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).close = reporterOptions.close || "]"; |
| 62 | optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).verbose = reporterOptions.verbose || false; |
| 63 | |
| 64 | // tests started |
| 65 | runnerscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(runner).on(EVENT_RUN_BEGINscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/EVENT_RUN_BEGIN., function () { |
| 66 | process.stdout.write("\n"); |
| 67 | cursorscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/cursor..hidescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/hide0:(); |
| 68 | }); |
| 69 | |
| 70 | // tests complete |
| 71 | runnerscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(runner).on(EVENT_TEST_ENDscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/EVENT_TEST_END., function () { |
| 72 | complete++; |
| 73 | |
| 74 | var percent = complete / total; |
| 75 | var n = (width * percent) | 0; |
| 76 | var i = width - n; |
| 77 | |
| 78 | if (n === lastN && !optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).verbose) { |
| 79 | // Don't re-render the line if it hasn't changed |
| 80 | return; |
| 81 | } |
| 82 | lastN = n; |
| 83 | |
| 84 | cursorscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/cursor..CRscip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/CR0:(); |
| 85 | process.stdout.write("\u001b[J"); |
| 86 | process.stdout.write(colorscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/color.("progress", " " + optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).open)); |
| 87 | process.stdout.write(Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#(n).joinscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#join().(optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).complete)); |
| 88 | process.stdout.write(Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#(i).joinscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#join().(optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).incomplete)); |
| 89 | process.stdout.write(colorscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/color.("progress", optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).close)); |
| 90 | if (optionsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(options).verbose) { |
| 91 | process.stdout.write(colorscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/color.("progress", " " + complete + " of " + total)); |
| 92 | } |
| 93 | }); |
| 94 | |
| 95 | // tests are complete, output some stats |
| 96 | // and the failures if any |
| 97 | runnerscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress().(runner).once(EVENT_RUN_ENDscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/EVENT_RUN_END., function () { |
| 98 | cursorscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/cursor..showscip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/show0:(); |
| 99 | process.stdout.write("\n"); |
| 100 | self.epilogue(); |
| 101 | }); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Inherit from `Base.prototype`. |
| 106 | */ |
| 107 | inheritsscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/inherits.(Progressscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress()., Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base().); |
| 108 | |
| 109 | Progressscip-typescript npm mocha 11.7.7 lib/reporters/`progress.js`/Progress()..description = "a progress bar"; |