MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / HTML

Function HTML

misc/test-browser/mocha.js:16639–16827  ·  view source on GitHub ↗

* Constructs a new `HTML` reporter instance. * * @public * @class * @memberof Mocha.reporters * @extends Mocha.reporters.Base * @param {Runner} runner - Instance triggers reporter actions. * @param {Object} [options] - runner options

(runner, options)

Source from the content-addressed store, hash-verified

16637 * @param {Object} [options] - runner options
16638 */
16639 function HTML(runner, options) {
16640 Base.call(this, runner, options);
16641
16642 var self = this;
16643 var stats = this.stats;
16644 var stat = fragment(statsTemplate);
16645 var items = stat.getElementsByTagName('li');
16646 var passes = items[1].getElementsByTagName('em')[0];
16647 var passesLink = items[1].getElementsByTagName('a')[0];
16648 var failures = items[2].getElementsByTagName('em')[0];
16649 var failuresLink = items[2].getElementsByTagName('a')[0];
16650 var duration = items[3].getElementsByTagName('em')[0];
16651 var canvas = stat.getElementsByTagName('canvas')[0];
16652 var report = fragment('<ul id="mocha-report"></ul>');
16653 var stack = [report];
16654 var progress;
16655 var ctx;
16656 var root = document.getElementById('mocha');
16657
16658 if (canvas.getContext) {
16659 var ratio = window.devicePixelRatio || 1;
16660 canvas.style.width = canvas.width;
16661 canvas.style.height = canvas.height;
16662 canvas.width *= ratio;
16663 canvas.height *= ratio;
16664 ctx = canvas.getContext('2d');
16665 ctx.scale(ratio, ratio);
16666 progress = new Progress();
16667 }
16668
16669 if (!root) {
16670 return error('#mocha div missing, add it to your document');
16671 }
16672
16673 // pass toggle
16674 on(passesLink, 'click', function (evt) {
16675 evt.preventDefault();
16676 unhide();
16677 var name = /pass/.test(report.className) ? '' : ' pass';
16678 report.className = report.className.replace(/fail|pass/g, '') + name;
16679 if (report.className.trim()) {
16680 hideSuitesWithout('test pass');
16681 }
16682 });
16683
16684 // failure toggle
16685 on(failuresLink, 'click', function (evt) {
16686 evt.preventDefault();
16687 unhide();
16688 var name = /fail/.test(report.className) ? '' : ' fail';
16689 report.className = report.className.replace(/fail|pass/g, '') + name;
16690 if (report.className.trim()) {
16691 hideSuitesWithout('test fail');
16692 }
16693 });
16694
16695 root.appendChild(stat);
16696 root.appendChild(report);

Callers

nothing calls this directly

Calls 12

fragmentFunction · 0.85
errorFunction · 0.85
onFunction · 0.85
unhideFunction · 0.85
hideSuitesWithoutFunction · 0.85
escapeFunction · 0.85
updateStatsFunction · 0.85
appendToStackFunction · 0.85
callMethod · 0.65
onMethod · 0.65
toStringMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected