mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-28 14:04:45 -04:00
Refactor test runner.
This commit is contained in:
parent
530e9c3859
commit
248e7efdb0
2 changed files with 14 additions and 11 deletions
|
@ -28,7 +28,7 @@
|
||||||
font-family: Roboto, Helvetica, Arial, sans-serif;
|
font-family: Roboto, Helvetica, Arial, sans-serif;
|
||||||
background: @col-white;
|
background: @col-white;
|
||||||
|
|
||||||
#mocha-custom {
|
#mocha-bar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
|
|
@ -3,11 +3,14 @@
|
||||||
|
|
||||||
var showOnlyFailures = false;
|
var showOnlyFailures = false;
|
||||||
var template =
|
var template =
|
||||||
'<div id="mocha-custom">' +
|
'<div id="mocha-bar">' +
|
||||||
'<a href="index.html"/>' +
|
'<a class="title" href="?">' + document.title + '</a>' +
|
||||||
'<div class="stats"/>' +
|
'<div class="stats"/>' +
|
||||||
'<div class="progress"/>' +
|
'<div class="progress"/>' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
var $mochaBar = $(template);
|
||||||
|
var $mochaStats = $mochaBar.find('.stats');
|
||||||
|
var $mochaProgress = $mochaBar.find('.progress');
|
||||||
|
|
||||||
|
|
||||||
function toggleFailureFilter(ev) {
|
function toggleFailureFilter(ev) {
|
||||||
|
@ -59,12 +62,12 @@ function onEnd() {
|
||||||
var stats = (runner.stats.duration / 1000.0).toFixed(3) + 's';
|
var stats = (runner.stats.duration / 1000.0).toFixed(3) + 's';
|
||||||
|
|
||||||
if (failed) {
|
if (failed) {
|
||||||
$('#mocha-custom .stats').on('click', toggleFailureFilter);
|
$mochaStats.on('click', toggleFailureFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#mocha-custom').addClass(failed ? 'fail' : 'pass');
|
$mochaBar.addClass(failed ? 'fail' : 'pass');
|
||||||
$('#mocha-custom .progress').hide();
|
$mochaProgress.hide();
|
||||||
$('#mocha-custom .stats').text(stats);
|
$mochaStats.text(stats);
|
||||||
$('#mocha-report .suite').each(addSuiteStats);
|
$('#mocha-report .suite').each(addSuiteStats);
|
||||||
$('#mocha-report code').each(fixCodeFormatting);
|
$('#mocha-report code').each(fixCodeFormatting);
|
||||||
}
|
}
|
||||||
|
@ -77,21 +80,21 @@ function onTest() {
|
||||||
var stats = ((new Date().getTime() - runner.stats.start) / 1000.0).toFixed(3) + 's';
|
var stats = ((new Date().getTime() - runner.stats.start) / 1000.0).toFixed(3) + 's';
|
||||||
|
|
||||||
if (runner.stats.failures) {
|
if (runner.stats.failures) {
|
||||||
$('#mocha-custom').addClass('fail');
|
$mochaBar.addClass('fail');
|
||||||
}
|
}
|
||||||
$('#mocha-custom .progress').css('width', (100 - percent) + '%');
|
$mochaProgress.css('width', (100 - percent) + '%');
|
||||||
$('#mocha-custom .stats').text(stats);
|
$mochaStats.text(stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupMocha() {
|
function setupMocha() {
|
||||||
|
|
||||||
window.assert = chai.assert;
|
window.assert = chai.assert;
|
||||||
mocha.setup('bdd');
|
mocha.setup('bdd');
|
||||||
|
$(function () { $mochaBar.appendTo('#mocha'); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function runMocha() {
|
function runMocha() {
|
||||||
|
|
||||||
$(template).appendTo('#mocha').find('a').text(document.title);
|
|
||||||
mocha.run().on('test', onTest).on('end', onEnd);
|
mocha.run().on('test', onTest).on('end', onEnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue