handle failed async tests

This commit is contained in:
rolux 2012-06-12 15:30:58 +02:00
parent 8e144aed87
commit b9c74fe895

View file

@ -184,6 +184,7 @@ Ox.DocPage = function(options, self) {
); );
if (section == 'tests') { if (section == 'tests') {
item.tests.forEach(function(test) { item.tests.forEach(function(test) {
var isAsync = test.expected && /(.+Ox\.test\()/.test(test.statement);
$elements.push( $elements.push(
$('<div>') $('<div>')
.addClass(className) .addClass(className)
@ -193,23 +194,36 @@ Ox.DocPage = function(options, self) {
+ Ox.encodeHTMLEntities(test.statement) + Ox.encodeHTMLEntities(test.statement)
.replace(/ /g, '&nbsp;') .replace(/ /g, '&nbsp;')
.replace(/\n/g, '<br>\n&nbsp;&nbsp;') .replace(/\n/g, '<br>\n&nbsp;&nbsp;')
+ '</b></code>' + '</b>'
) + (
); test.passed === false && isAsync
test.expected && $elements.push( ? ' <span class="OxFailed"> // actual: '
$('<div>') + Ox.encodeHTMLEntities(test.actual)
.addClass(className)
.css({marginLeft: (level * 32 + 16) + 'px'})
.html(
'<code>' + Ox.encodeHTMLEntities(test.actual || test.expected) + (
test.passed === false
? ' <span class="OxFailed"> // expected: '
+ Ox.encodeHTMLEntities(test.expected)
+ '</span>' + '</span>'
: '' : ''
) + '</code>' )
+ '</code>'
) )
); );
if (test.expected) {
$elements.push(
$('<div>')
.addClass(className)
.css({marginLeft: (level * 32 + 16) + 'px'})
.html(
'<code>'
+ Ox.encodeHTMLEntities(test.actual || test.expected)
+ (
test.passed === false && !isAsync
? ' <span class="OxFailed"> // expected: '
+ Ox.encodeHTMLEntities(test.expected)
+ '</span>'
: ''
)
+ '</code>'
)
);
}
}); });
} else if (section == 'source') { } else if (section == 'source') {
// fixme: not the right place to fix path // fixme: not the right place to fix path