save test results

This commit is contained in:
rolux 2012-06-12 16:55:13 +02:00
parent 0d2f082779
commit 28075133ee
2 changed files with 14 additions and 6 deletions

View file

@ -382,6 +382,7 @@ Ox.load(function() {
path: 'dev/',
references: /\b(Ox\.[\w\$]+)\b/g,
replace: [app.re.code],
results: app.data.testResults || void 0,
selected: app.user.item.doc,
showTests: true
})
@ -401,6 +402,9 @@ Ox.load(function() {
.bindEventOnce({
load: function(data) {
app.data.docItems = data.items;
},
tests: function(data) {
app.data.testResults = data.results;
}
});
},

View file

@ -47,6 +47,7 @@ Ox.DocPanel = function(options, self) {
replace: [],
resizable: false,
resize: [128, 256, 384],
results: null,
runTests: false,
selected: '',
showTests: false,
@ -60,7 +61,9 @@ Ox.DocPanel = function(options, self) {
}
});
self.results = {};
if (!self.options.results) {
self.options.results = {};
}
self.$testsButton = Ox.Button({title: 'Run Tests'})
.css({float: 'left', margin: '4px'})
@ -109,7 +112,7 @@ Ox.DocPanel = function(options, self) {
self.$sidebar.replaceElement(0, self.$toolbar);
renderList();
self.options.runTests && runTests();
that.triggerEvent('load', {items: docItems});
that.triggerEvent('load', {items: self.options.items});
});
});
} else {
@ -153,8 +156,8 @@ Ox.DocPanel = function(options, self) {
}
function getIcon(id, expanded) {
var $icon = null, results = self.results[id];
if (!Ox.isEmpty(self.results)) {
var $icon = null, results = self.options.results[id];
if (!Ox.isEmpty(self.options.results)) {
$icon = Ox.Theme.getColorImage(
'symbol' + (expanded === true ? 'Down' : expanded === false ? 'Right' : 'Center'),
!results ? 'none' : results.failed === 0 ? 'passed' : 'failed',
@ -281,13 +284,14 @@ Ox.DocPanel = function(options, self) {
item.section ? item.module + '/' + item.section + '/' : [],
item.module + '/' + (item.section ? item.section + '/' : '') + item.name
).forEach(function(key) {
self.results[key] = self.results[key] || {passed: 0, failed: 0};
self.results[key][passed]++;
self.options.results[key] = self.options.results[key] || {passed: 0, failed: 0};
self.options.results[key][passed]++;
});
});
self.$testsLabel.hide();
self.$testsButton.show();
renderList();
that.triggerEvent('tests', {results: self.options.results});
});
});
}