Files
freeCodeCamp/client/commonFramework/display-test-results.js
HelderSepu e6542fa00e Prevent scrolling on initial challenge run
- Add additional parameter to function displayTestResults

Correction to errors: Line exceeds the maximum line length of 80   max-len

Do not scroll on JS challenges
2016-06-21 20:22:30 -04:00

34 lines
965 B
JavaScript

window.common = (function({ $, common = { init: [] }}) {
common.displayTestResults = function displayTestResults(data = [], down) {
$('#testSuite').children().remove();
$('#testSuite').fadeIn('slow');
data.forEach(({ err = false, text = '' }) => {
var iconClass = err ?
'"ion-close-circled big-error-icon"' :
'"ion-checkmark-circled big-success-icon"';
$('<div></div>').html(`
<div class='row'>
<div class='col-xs-2 text-center'>
<i class=${iconClass}></i>
</div>
<div class='col-xs-10 test-output'>
${text.split('message: ').pop().replace(/\'\);/g, '')}
</div>
<div class='ten-pixel-break'/>
</div>
`)
.appendTo($('#testSuite'));
});
if (down) {
$('#scroll-locker').animate(
{ scrollTop: $(document).height() }, 'slow'
);
}
return data;
};
return common;
}(window));