@typed/test
Version:
Testing made simple.
29 lines • 951 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const defaultStats = { passing: 0, failing: 0, skipped: 0 };
function getTestStats(testResults, seed = defaultStats) {
return testResults.reduce(getStat, seed);
}
exports.getTestStats = getTestStats;
function getStat(stats, result) {
if (result.type === 'group') {
return getTestStats(result.results, stats);
}
if (result.type === 'fail') {
return failed(stats);
}
if (result.type === 'skip') {
return skipped(stats);
}
return passed(stats);
}
function passed(stats) {
return Object.assign(Object.assign({}, stats), { passing: stats.passing + 1 });
}
function failed(stats) {
return Object.assign(Object.assign({}, stats), { failing: stats.failing + 1 });
}
function skipped(stats) {
return Object.assign(Object.assign({}, stats), { skipped: stats.skipped + 1 });
}
//# sourceMappingURL=getTestStats.js.map