beforeEach now supports waits and Runs blocks
This commit is contained in:
14
src/Queue.js
14
src/Queue.js
@@ -2,14 +2,25 @@ jasmine.Queue = function() {
|
||||
this.blocks = [];
|
||||
this.running = false;
|
||||
this.index = 0;
|
||||
this.offset = 0;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.addBefore = function (block) {
|
||||
this.blocks.unshift(block);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.add = function(block) {
|
||||
this.blocks.push(block);
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.insertNext = function (block) {
|
||||
this.blocks.splice((this.index + this.offset + 1), 0, block);
|
||||
this.offset++;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.start = function(onComplete) {
|
||||
var self = this;
|
||||
self.running = true;
|
||||
self.onComplete = onComplete;
|
||||
if (self.blocks[0]) {
|
||||
self.blocks[0].execute(function () {
|
||||
@@ -26,6 +37,7 @@ jasmine.Queue.prototype.isRunning = function () {
|
||||
|
||||
jasmine.Queue.prototype._next = function () {
|
||||
var self = this;
|
||||
self.offset = 0;
|
||||
self.index++;
|
||||
if (self.index < self.blocks.length) {
|
||||
self.blocks[self.index].execute(function () {self._next();});
|
||||
@@ -35,10 +47,10 @@ jasmine.Queue.prototype._next = function () {
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.finish = function () {
|
||||
this.running = false;
|
||||
if (this.onComplete) {
|
||||
this.onComplete();
|
||||
}
|
||||
this.running = false;
|
||||
};
|
||||
|
||||
jasmine.Queue.prototype.getResults = function () {
|
||||
|
||||
Reference in New Issue
Block a user