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 () {
|
||||
'use strict';
|
||||
|
||||
function onEnd() {
|
||||
var showOnlyFailures = false;
|
||||
|
||||
var runner = this;
|
||||
var failed = runner.stats.failures > 0;
|
||||
var stats = (runner.stats.duration / 1000.0).toFixed(2) + 's';
|
||||
function toggleFailureFilter(ev) {
|
||||
|
||||
if (failed) {
|
||||
var onlyFailures = false;
|
||||
$('#report .stats').on('click', function (ev) {
|
||||
ev.stopImmediatePropagation();
|
||||
|
||||
onlyFailures = !onlyFailures;
|
||||
if (onlyFailures) {
|
||||
showOnlyFailures = !showOnlyFailures;
|
||||
if (showOnlyFailures) {
|
||||
$('.suite, .test').hide();
|
||||
$('.suite.fail, .test.fail').show();
|
||||
} else {
|
||||
$('.suite, .test').show();
|
||||
}
|
||||
ev.stopImmediatePropagation();
|
||||
});
|
||||
}
|
||||
|
||||
$('#report').addClass(failed ? 'fail' : 'pass');
|
||||
$('#report .progress').hide();
|
||||
$('#report .stats').text(stats);
|
||||
|
||||
$('#mocha-overlay .suite').each(function () {
|
||||
function addSuiteStats() {
|
||||
|
||||
var $suite = $(this);
|
||||
|
||||
|
@ -43,21 +33,36 @@ function onEnd() {
|
|||
|
||||
$suite.addClass(tests === passed ? 'pass' : 'fail');
|
||||
$header.append($count);
|
||||
});
|
||||
}
|
||||
|
||||
$('#mocha-overlay code').each(function () {
|
||||
function fixCodeFormatting() {
|
||||
|
||||
var $code = $(this);
|
||||
$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() {
|
||||
|
||||
var runner = this;
|
||||
var complete = runner.stats.tests;
|
||||
var total = runner.total;
|
||||
var percent = 100.0 - 100.0 * complete / total;
|
||||
var percent = 100.0 - 100.0 * runner.stats.tests / runner.total;
|
||||
|
||||
if (runner.stats.failures) {
|
||||
$('#report').addClass('fail');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue