Properly display tests
This commit is contained in:
@ -10,7 +10,7 @@ window.common = (function({ common = { init: [] }}) {
|
|||||||
common.addTestsToString = function({ code, tests = [], ...rest }) {
|
common.addTestsToString = function({ code, tests = [], ...rest }) {
|
||||||
const userTests = [];
|
const userTests = [];
|
||||||
|
|
||||||
code = tests.reduce((code, test) => '\n' + code + test, code);
|
code = tests.reduce((code, test) => code + test + '\n', code + '\n');
|
||||||
|
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
var match = BDDregex.exec(code);
|
var match = BDDregex.exec(code);
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
window.common = (function({ $, common = { init: [] }}) {
|
window.common = (function({ $, common = { init: [] }}) {
|
||||||
|
|
||||||
common.displayTestResults = function displayTestResults(data = []) {
|
common.displayTestResults = function displayTestResults(data = []) {
|
||||||
|
$('#testSuite').children().remove();
|
||||||
data.forEach(({ err = false, text = '' }) => {
|
data.forEach(({ err = false, text = '' }) => {
|
||||||
|
console.log('err', err);
|
||||||
var iconClass = err ?
|
var iconClass = err ?
|
||||||
'"ion-checkmark-circled big-success-icon"' :
|
'"ion-close-circled big-error-icon"' :
|
||||||
'"ion-close-circled big-error-icon"';
|
'"ion-checkmark-circled big-success-icon"';
|
||||||
|
|
||||||
$('#testSuite').children().remove();
|
|
||||||
$('<div></div>').html(`
|
$('<div></div>').html(`
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
<div class='col-xs-2 text-center'>
|
<div class='col-xs-2 text-center'>
|
||||||
|
@ -30,9 +30,10 @@ $(document).ready(function() {
|
|||||||
return common.executeChallenge$();
|
return common.executeChallenge$();
|
||||||
})
|
})
|
||||||
.subscribe(
|
.subscribe(
|
||||||
({ output, original, userTests }) => {
|
({ output, original, tests }) => {
|
||||||
common.updateOutputDisplay(output);
|
common.updateOutputDisplay(output);
|
||||||
common.codeStorage.updateStorage(challengeName, original);
|
common.codeStorage.updateStorage(challengeName, original);
|
||||||
|
common.displayTestResults(tests);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ window.common = (function(global) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
common.reassembleTest = function reassembleTest(code = '', { line, text }) {
|
common.reassembleTest = function reassembleTest(code = '', { line, text }) {
|
||||||
var regexp = new RegExp('\/\/' + line + common.salt);
|
var regexp = new RegExp('//' + line + common.salt);
|
||||||
return code.replace(regexp, text);
|
return code.replace(regexp, text);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ window.common = (function(global) {
|
|||||||
try {
|
try {
|
||||||
if (test) {
|
if (test) {
|
||||||
/* eslint-disable no-eval */
|
/* eslint-disable no-eval */
|
||||||
eval(common.reassembleTest(test, code));
|
eval(common.reassembleTest(code, test));
|
||||||
/* eslint-enable no-eval */
|
/* eslint-enable no-eval */
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Reference in New Issue
Block a user