Files
freeCodeCamp/client/commonFramework/display-test-results.js
Helder ce46d1906b Animate #testSuite to focus user on errors
- As soon as the user clicks the button we hide('slow') the div #testSuite
- Then on displayTestResults we show it.

Use fadeOut/fadeIn instead of hide/show

Scroll the div #scroll-locker to the bottom
- Fix for some challenges with long contents on div #scroll-locker

Fix Err: Strings must use singlequote quotes
2016-06-18 16:04:36 -04:00

30 lines
911 B
JavaScript

window.common = (function({ $, common = { init: [] }}) {
common.displayTestResults = function displayTestResults(data = []) {
$('#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'));
});
$('#scroll-locker').animate({ scrollTop: $(document).height() }, 'slow');
return data;
};
return common;
}(window));