in Ox.DocPage, display test results

This commit is contained in:
rolux 2012-06-12 13:16:06 +02:00
parent 963e594397
commit 359a8984d3

View file

@ -180,24 +180,32 @@ Ox.DocPage = function(options, self) {
);
if (section == 'tests') {
item.tests.forEach(function(test) {
$elements.push($('<div>')
.addClass(className)
.css({marginLeft: (level * 32 + 16) + 'px'})
.html(
'<code><b>&gt;&nbsp;'
+ Ox.encodeHTMLEntities(test.statement)
.replace(/ /g, '&nbsp;')
.replace(/\n/g, '<br>\n&nbsp;&nbsp;')
+ '</b></code>'
)
$elements.push(
$('<div>')
.addClass(className)
.css({marginLeft: (level * 32 + 16) + 'px'})
.html(
'<code><b>&gt;&nbsp;'
+ Ox.encodeHTMLEntities(test.statement)
.replace(/ /g, '&nbsp;')
.replace(/\n/g, '<br>\n&nbsp;&nbsp;')
+ '</b></code>'
)
);
test.expected && $elements.push(
$('<div>')
.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>'
: ''
) + '</code>'
)
);
test.expected && $elements.push($('<div>')
.addClass(className)
.css({marginLeft: (level * 32 + 16) + 'px'})
.html(
'<code>' + Ox.encodeHTMLEntities(test.expected) + '</code>'
)
)
});
} else if (section == 'source') {
// fixme: not the right place to fix path