2014-03-24 06:59:45 +01:00
|
|
|
(function() {
|
2014-04-16 00:06:11 +02:00
|
|
|
var coverObjects = [], modulesExecuted = {}, log = [], currentModule;
|
2014-03-24 06:59:45 +01:00
|
|
|
|
|
|
|
QUnit.config.reorder = false;
|
2014-04-16 00:06:11 +02:00
|
|
|
QUnit.config.hidepassed = true;
|
2014-03-24 06:59:45 +01:00
|
|
|
|
2014-07-17 02:58:41 +02:00
|
|
|
window.editor = window.inlineEditor = null;
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
var oldModule = module;
|
|
|
|
|
|
|
|
QUnit.moduleStart(function(details) {
|
2014-04-16 00:06:11 +02:00
|
|
|
currentModule = details.name;
|
2014-03-24 06:59:45 +01:00
|
|
|
modulesExecuted[details.name] = true;
|
|
|
|
|
|
|
|
tinymce.remove();
|
|
|
|
document.getElementById('view').innerHTML = '<textarea></textarea>';
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.moduleDone(function() {
|
|
|
|
tinymce.remove();
|
|
|
|
window.editor = window.inlineEditor = null;
|
|
|
|
});
|
|
|
|
|
2014-04-16 00:06:11 +02:00
|
|
|
// Sauce labs
|
|
|
|
QUnit.testStart(function(testDetails) {
|
|
|
|
QUnit.log = function(details) {
|
|
|
|
if (!details.result) {
|
|
|
|
details.name = currentModule + ':' + testDetails.name;
|
|
|
|
log.push(details);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
QUnit.done(function(results) {
|
2014-03-24 06:59:45 +01:00
|
|
|
document.getElementById("view").style.display = 'none';
|
|
|
|
|
|
|
|
if (window.__$coverObject) {
|
|
|
|
coverObjects.push(window.__$coverObject);
|
|
|
|
|
|
|
|
$('<button>Coverage report</button>').on('click', function() {
|
|
|
|
window.open('coverage/index.html', 'coverage');
|
|
|
|
}).appendTo(document.body);
|
|
|
|
}
|
2014-04-16 00:06:11 +02:00
|
|
|
|
|
|
|
// Sauce labs
|
|
|
|
var tests = [];
|
|
|
|
for (var i = 0; i < log.length; i++) {
|
|
|
|
tests.push({
|
|
|
|
name: log[i].name,
|
|
|
|
result: log[i].result,
|
|
|
|
expected: log[i].expected,
|
|
|
|
actual: log[i].actual,
|
|
|
|
source: log[i].source
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
results.tests = tests;
|
|
|
|
window.global_test_results = results;
|
2014-03-24 06:59:45 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
window.module = function(name, settings) {
|
|
|
|
settings = settings || {};
|
|
|
|
|
|
|
|
if (settings.setupModule) {
|
|
|
|
QUnit.moduleStart(function(details) {
|
|
|
|
if (details.name == name) {
|
|
|
|
settings.setupModule();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.teardownModule) {
|
|
|
|
QUnit.moduleDone(function(details) {
|
|
|
|
if (details.name == name) {
|
|
|
|
settings.teardownModule();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
oldModule(name, settings);
|
|
|
|
};
|
|
|
|
|
|
|
|
window.getCoverObject = function() {
|
|
|
|
var coverObject = {}, fileName, gaps, gap, count, targetModuleName;
|
|
|
|
var isScoped = document.location.search.indexOf('module=') != -1;
|
|
|
|
|
|
|
|
for (var i = 0, length = coverObjects.length; i < length; i++) {
|
|
|
|
for (fileName in coverObjects[i]) {
|
|
|
|
gaps = coverObjects[i][fileName];
|
|
|
|
|
|
|
|
if (isScoped && fileName.indexOf('js/tinymce/classes') === 0) {
|
|
|
|
targetModuleName = "tinymce." + fileName.substr('js/tinymce/classes'.length + 1).replace(/\//g, '.');
|
|
|
|
targetModuleName = targetModuleName.replace(/\.js$/, '');
|
|
|
|
|
|
|
|
if (!modulesExecuted[targetModuleName]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!coverObject.hasOwnProperty(fileName)) {
|
|
|
|
coverObject[fileName] = gaps;
|
|
|
|
} else {
|
|
|
|
for (gap in gaps) {
|
|
|
|
if (gap === '__code') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
count = gaps[gap];
|
|
|
|
|
|
|
|
if (!coverObject[fileName].hasOwnProperty(gap)) {
|
|
|
|
coverObject[fileName][gap] = count;
|
|
|
|
} else {
|
|
|
|
coverObject[fileName][gap] += count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return coverObject;
|
|
|
|
};
|
|
|
|
})();
|