mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-24 20:14:37 -04:00
Refactor test code.
This commit is contained in:
parent
21c976bb3d
commit
b95aa583a9
1 changed files with 46 additions and 41 deletions
|
@ -1,32 +1,22 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function onEnd() {
|
var showOnlyFailures = false;
|
||||||
|
|
||||||
var runner = this;
|
function toggleFailureFilter(ev) {
|
||||||
var failed = runner.stats.failures > 0;
|
|
||||||
var stats = (runner.stats.duration / 1000.0).toFixed(2) + 's';
|
|
||||||
|
|
||||||
if (failed) {
|
ev.stopImmediatePropagation();
|
||||||
var onlyFailures = false;
|
|
||||||
$('#report .stats').on('click', function (ev) {
|
|
||||||
|
|
||||||
onlyFailures = !onlyFailures;
|
showOnlyFailures = !showOnlyFailures;
|
||||||
if (onlyFailures) {
|
if (showOnlyFailures) {
|
||||||
$('.suite, .test').hide();
|
$('.suite, .test').hide();
|
||||||
$('.suite.fail, .test.fail').show();
|
$('.suite.fail, .test.fail').show();
|
||||||
} else {
|
} else {
|
||||||
$('.suite, .test').show();
|
$('.suite, .test').show();
|
||||||
}
|
}
|
||||||
ev.stopImmediatePropagation();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#report').addClass(failed ? 'fail' : 'pass');
|
function addSuiteStats() {
|
||||||
$('#report .progress').hide();
|
|
||||||
$('#report .stats').text(stats);
|
|
||||||
|
|
||||||
$('#mocha-overlay .suite').each(function () {
|
|
||||||
|
|
||||||
var $suite = $(this);
|
var $suite = $(this);
|
||||||
|
|
||||||
|
@ -43,21 +33,36 @@ function onEnd() {
|
||||||
|
|
||||||
$suite.addClass(tests === passed ? 'pass' : 'fail');
|
$suite.addClass(tests === passed ? 'pass' : 'fail');
|
||||||
$header.append($count);
|
$header.append($count);
|
||||||
});
|
}
|
||||||
|
|
||||||
$('#mocha-overlay code').each(function () {
|
function fixCodeFormatting() {
|
||||||
|
|
||||||
var $code = $(this);
|
var $code = $(this);
|
||||||
$code.text($code.text().trim().replace(/;\n\s*/g, ';\n'));
|
$code.text($code.text().trim().replace(/;\n\s*/g, ';\n'));
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function onEnd() {
|
||||||
|
|
||||||
|
var runner = this;
|
||||||
|
var failed = runner.stats.failures > 0;
|
||||||
|
var stats = (runner.stats.duration / 1000.0).toFixed(3) + 's';
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
$('#report .stats').on('click', toggleFailureFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#report').addClass(failed ? 'fail' : 'pass');
|
||||||
|
$('#report .progress').hide();
|
||||||
|
$('#report .stats').text(stats);
|
||||||
|
$('#mocha-overlay .suite').each(addSuiteStats);
|
||||||
|
$('#mocha-overlay code').each(fixCodeFormatting);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTest() {
|
function onTest() {
|
||||||
|
|
||||||
var runner = this;
|
var runner = this;
|
||||||
var complete = runner.stats.tests;
|
var percent = 100.0 - 100.0 * runner.stats.tests / runner.total;
|
||||||
var total = runner.total;
|
|
||||||
var percent = 100.0 - 100.0 * complete / total;
|
|
||||||
|
|
||||||
if (runner.stats.failures) {
|
if (runner.stats.failures) {
|
||||||
$('#report').addClass('fail');
|
$('#report').addClass('fail');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue