display test stats
This commit is contained in:
parent
e21354d7b4
commit
b915839305
1 changed files with 29 additions and 20 deletions
|
@ -61,29 +61,32 @@ Ox.DocPanel = function(options, self) {
|
|||
}
|
||||
});
|
||||
|
||||
if (!self.options.results) {
|
||||
self.options.results = {};
|
||||
}
|
||||
|
||||
self.$testsButton = Ox.Button({title: 'Run Tests'})
|
||||
.css({float: 'left', margin: '4px'})
|
||||
.bindEvent({click: runTests});
|
||||
self.$testsLabel = Ox.Label({title: 'Running Tests...'})
|
||||
.css({float: 'left', margin: '4px'})
|
||||
.hide();
|
||||
self.$toolbar = Ox.Bar({size: 24})
|
||||
.append(self.$testsButton)
|
||||
.append(self.$testsLabel)
|
||||
self.$toolbar = Ox.Bar({size: 24});
|
||||
self.$list = Ox.Element();
|
||||
self.$sidebar = Ox.SplitPanel({
|
||||
elements: [
|
||||
{element: Ox.Element(), size: 24},
|
||||
{element: Ox.Element()}
|
||||
{element: Ox.Element()},
|
||||
{element: Ox.Element(), size: 24}
|
||||
],
|
||||
orientation: 'vertical'
|
||||
});
|
||||
self.$page = Ox.Element();
|
||||
|
||||
if (!self.options.results) {
|
||||
self.options.results = {};
|
||||
self.$testsButton = Ox.Button({title: 'Run Tests'})
|
||||
.css({float: 'left', margin: '4px'})
|
||||
.bindEvent({click: runTests})
|
||||
.appendTo(self.$toolbar);
|
||||
self.$testsLabel = Ox.Label({title: 'Running Tests...'}).hide();
|
||||
} else {
|
||||
self.$testsLabel = Ox.Label({title: formatResults()});
|
||||
}
|
||||
|
||||
self.$testsLabel
|
||||
.css({float: 'left', margin: '4px'})
|
||||
.appendTo(self.$toolbar);
|
||||
|
||||
that.setElement(
|
||||
self.$panel = Ox.SplitPanel({
|
||||
elements: [
|
||||
|
@ -109,7 +112,7 @@ Ox.DocPanel = function(options, self) {
|
|||
}), function(docItems) {
|
||||
self.options.items = docItems;
|
||||
getExamples(function() {
|
||||
self.$sidebar.replaceElement(0, self.$toolbar);
|
||||
self.$sidebar.replaceElement(1, self.$toolbar);
|
||||
renderList();
|
||||
self.options.runTests && runTests();
|
||||
that.triggerEvent('load', {items: self.options.items});
|
||||
|
@ -117,12 +120,19 @@ Ox.DocPanel = function(options, self) {
|
|||
});
|
||||
} else {
|
||||
getExamples(function() {
|
||||
self.$sidebar.replaceElement(0, self.$toolbar);
|
||||
self.$sidebar.replaceElement(1, self.$toolbar);
|
||||
renderList();
|
||||
self.options.runTests && runTests();
|
||||
});
|
||||
}
|
||||
|
||||
function formatResults() {
|
||||
var results = self.options.results[''],
|
||||
tests = results.passed + results.failed;
|
||||
return tests + ' test' + (tests == 1 ? '' : 's') + ', '
|
||||
+ results.passed + ' passed, ' + results.failed + ' failed';
|
||||
}
|
||||
|
||||
function getExamples(callback) {
|
||||
var i = 0;
|
||||
if (self.options.examples && self.options.examples.length) {
|
||||
|
@ -265,7 +275,7 @@ Ox.DocPanel = function(options, self) {
|
|||
selectItem(data.ids.length ? data.ids[0] : '')
|
||||
}
|
||||
});
|
||||
self.$sidebar.replaceElement(1, self.$list);
|
||||
self.$sidebar.replaceElement(0, self.$list);
|
||||
selectItem(self.options.selected);
|
||||
}
|
||||
|
||||
|
@ -288,8 +298,7 @@ Ox.DocPanel = function(options, self) {
|
|||
self.options.results[key][passed]++;
|
||||
});
|
||||
});
|
||||
self.$testsLabel.hide();
|
||||
self.$testsButton.show();
|
||||
self.$testsLabel.options({title: formatResults()});
|
||||
renderList();
|
||||
that.triggerEvent('tests', {results: self.options.results});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue