handle failed async tests
This commit is contained in:
parent
8e144aed87
commit
b9c74fe895
1 changed files with 27 additions and 13 deletions
|
@ -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, ' ')
|
.replace(/ /g, ' ')
|
||||||
.replace(/\n/g, '<br>\n ')
|
.replace(/\n/g, '<br>\n ')
|
||||||
+ '</b></code>'
|
+ '</b>'
|
||||||
|
+ (
|
||||||
|
test.passed === false && isAsync
|
||||||
|
? ' <span class="OxFailed"> // actual: '
|
||||||
|
+ Ox.encodeHTMLEntities(test.actual)
|
||||||
|
+ '</span>'
|
||||||
|
: ''
|
||||||
|
)
|
||||||
|
+ '</code>'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
test.expected && $elements.push(
|
if (test.expected) {
|
||||||
|
$elements.push(
|
||||||
$('<div>')
|
$('<div>')
|
||||||
.addClass(className)
|
.addClass(className)
|
||||||
.css({marginLeft: (level * 32 + 16) + 'px'})
|
.css({marginLeft: (level * 32 + 16) + 'px'})
|
||||||
.html(
|
.html(
|
||||||
'<code>' + Ox.encodeHTMLEntities(test.actual || test.expected) + (
|
'<code>'
|
||||||
test.passed === false
|
+ Ox.encodeHTMLEntities(test.actual || test.expected)
|
||||||
|
+ (
|
||||||
|
test.passed === false && !isAsync
|
||||||
? ' <span class="OxFailed"> // expected: '
|
? ' <span class="OxFailed"> // expected: '
|
||||||
+ Ox.encodeHTMLEntities(test.expected)
|
+ Ox.encodeHTMLEntities(test.expected)
|
||||||
+ '</span>'
|
+ '</span>'
|
||||||
: ''
|
: ''
|
||||||
) + '</code>'
|
)
|
||||||
|
+ '</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
|
||||||
|
|
Loading…
Reference in a new issue