mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
Have iit have higher priority then ddesrcibe
This commit is contained in:
parent
498ad0a3be
commit
b2dc2ce0b5
1 changed files with 32 additions and 25 deletions
|
|
@ -6,14 +6,14 @@
|
|||
var rootDescribes = new Describes(window);
|
||||
var describePath = [];
|
||||
rootDescribes.collectMode();
|
||||
|
||||
|
||||
var jasmineTest = TestCase('Jasmine Adapter Tests', null, 'jasmine test case');
|
||||
|
||||
|
||||
var jasminePlugin = {
|
||||
name:'jasmine',
|
||||
runTestConfiguration: function(testRunConfiguration, onTestDone, onTestRunConfigurationComplete){
|
||||
if (testRunConfiguration.testCaseInfo_.template_ !== jasmineTest) return;
|
||||
|
||||
|
||||
var jasmineEnv = jasmine.currentEnv_ = new jasmine.Env();
|
||||
rootDescribes.playback();
|
||||
var specLog = jstestdriver.console.log_ = [];
|
||||
|
|
@ -45,24 +45,24 @@
|
|||
if (!resultItems[i].passed()) {
|
||||
state = resultItems[i].message.match(/AssertionError:/) ? 'error' : 'failed';
|
||||
messages.push({
|
||||
message: resultItems[i].toString(),
|
||||
name: resultItems[i].trace.name,
|
||||
stack: formatStack(resultItems[i].trace.stack)
|
||||
});
|
||||
message: resultItems[i].toString(),
|
||||
name: resultItems[i].trace.name,
|
||||
stack: formatStack(resultItems[i].trace.stack)
|
||||
});
|
||||
}
|
||||
}
|
||||
onTestDone(
|
||||
new jstestdriver.TestResult(
|
||||
suite.getFullName(),
|
||||
spec.description,
|
||||
state,
|
||||
suite.getFullName(),
|
||||
spec.description,
|
||||
state,
|
||||
jstestdriver.angular.toJson(messages),
|
||||
specLog.join('\n'),
|
||||
end - start));
|
||||
},
|
||||
|
||||
reportSuiteResults: function(suite) {},
|
||||
|
||||
|
||||
reportRunnerResults: function(runner) {
|
||||
onTestRunConfigurationComplete();
|
||||
}
|
||||
|
|
@ -93,13 +93,17 @@
|
|||
var describes = {};
|
||||
var beforeEachs = {};
|
||||
var afterEachs = {};
|
||||
var exclusive;
|
||||
// Here we store:
|
||||
// 0: everyone runs
|
||||
// 1: run everything under ddescribe
|
||||
// 2: run only iits (ignore ddescribe)
|
||||
var exclusive = 0;
|
||||
var collectMode = true;
|
||||
intercept('describe', describes);
|
||||
intercept('xdescribe', describes);
|
||||
intercept('beforeEach', beforeEachs);
|
||||
intercept('afterEach', afterEachs);
|
||||
|
||||
|
||||
function intercept(functionName, collection){
|
||||
window[functionName] = function(desc, fn){
|
||||
if (collectMode) {
|
||||
|
|
@ -112,11 +116,15 @@
|
|||
};
|
||||
}
|
||||
window.ddescribe = function(name, fn){
|
||||
exclusive = true;
|
||||
console.log('ddescribe', name);
|
||||
if (exclusive < 1) {
|
||||
exclusive = 1; // run ddescribe only
|
||||
}
|
||||
window.describe(name, function(){
|
||||
var oldIt = window.it;
|
||||
window.it = window.iit;
|
||||
window.it = function(name, fn){
|
||||
fn.exclusive = 1; // run anything under ddescribe
|
||||
jasmine.getEnv().it(name, fn);
|
||||
};
|
||||
try {
|
||||
fn.call(this);
|
||||
} finally {
|
||||
|
|
@ -125,34 +133,33 @@
|
|||
});
|
||||
};
|
||||
window.iit = function(name, fn){
|
||||
exclusive = fn.exclusive = true;
|
||||
console.log(fn);
|
||||
exclusive = fn.exclusive = 2; // run only iits
|
||||
jasmine.getEnv().it(name, fn);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
this.collectMode = function() {
|
||||
collectMode = true;
|
||||
exclusive = false;
|
||||
exclusive = 0; // run everything
|
||||
};
|
||||
this.playback = function(){
|
||||
collectMode = false;
|
||||
playback(beforeEachs);
|
||||
playback(afterEachs);
|
||||
playback(describes);
|
||||
|
||||
|
||||
function playback(set) {
|
||||
for ( var name in set) {
|
||||
set[name]();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.isExclusive = function(spec) {
|
||||
if (exclusive) {
|
||||
var blocks = spec.queue.blocks;
|
||||
for ( var i = 0; i < blocks.length; i++) {
|
||||
if (blocks[i].func.exclusive) {
|
||||
if (blocks[i].func.exclusive >= exclusive) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -161,7 +168,7 @@
|
|||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
})(window);
|
||||
|
||||
// Patch Jasmine for proper stack traces
|
||||
|
|
|
|||
Loading…
Reference in a new issue