Properly display tests
This commit is contained in:
@ -10,7 +10,7 @@ window.common = (function({ common = { init: [] }}) {
|
||||
common.addTestsToString = function({ code, tests = [], ...rest }) {
|
||||
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 match = BDDregex.exec(code);
|
||||
|
@ -1,12 +1,13 @@
|
||||
window.common = (function({ $, common = { init: [] }}) {
|
||||
|
||||
common.displayTestResults = function displayTestResults(data = []) {
|
||||
$('#testSuite').children().remove();
|
||||
data.forEach(({ err = false, text = '' }) => {
|
||||
console.log('err', 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 class='row'>
|
||||
<div class='col-xs-2 text-center'>
|
||||
|
@ -30,9 +30,10 @@ $(document).ready(function() {
|
||||
return common.executeChallenge$();
|
||||
})
|
||||
.subscribe(
|
||||
({ output, original, userTests }) => {
|
||||
({ output, original, tests }) => {
|
||||
common.updateOutputDisplay(output);
|
||||
common.codeStorage.updateStorage(challengeName, original);
|
||||
common.displayTestResults(tests);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -82,7 +82,7 @@ window.common = (function(global) {
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
|
@ -18,7 +18,7 @@ window.common = (function(global) {
|
||||
try {
|
||||
if (test) {
|
||||
/* eslint-disable no-eval */
|
||||
eval(common.reassembleTest(test, code));
|
||||
eval(common.reassembleTest(code, test));
|
||||
/* eslint-enable no-eval */
|
||||
}
|
||||
} catch (e) {
|
||||
|
Reference in New Issue
Block a user