Fix tests for new stack clearing in IE

This commit is contained in:
Gregg Van Hove
2016-10-14 15:53:00 -07:00
parent 9750ae59e7
commit 0e9b9a11c3
4 changed files with 22 additions and 15 deletions

View File

@@ -1324,13 +1324,16 @@ getJasmineRequireObj().clearStack = function(j$) {
if (global && global.process && j$.isFunction_(global.process.nextTick)) {
return global.process.nextTick;
} else if (j$.isFunction_(global.setImmediate)) {
return global.setImmediate;
var realSetImmediate = global.setImmediate;
return function(fn) {
realSetImmediate(fn);
};
} else if (!j$.util.isUndefined(global.MessageChannel)) {
return messageChannelImpl(global);
} else if (j$.isFunction_(global.setTimeout)) {
} else {
var realSetTimeout = global.setTimeout;
return function clearStack(fn) {
realSetTimeout(fn, 0);
Function.prototype.apply.apply(realSetTimeout, [global, [fn, 0]]);
};
}
}

View File

@@ -1,12 +1,6 @@
describe("ClearStack", function() {
it("works in an integrationy way", function(done) {
var global = {
setTimeout: typeof setTimeout === 'undefined' ? undefined : setTimeout,
setImmediate: typeof setImmediate === 'undefined' ? undefined : setImmediate,
MessageChannel: typeof MessageChannel === 'undefined' ? undefined : MessageChannel,
process: typeof process === 'undefined' ? undefined : process
},
clearStack = jasmineUnderTest.getClearStack(global);
var clearStack = jasmineUnderTest.getClearStack(jasmineUnderTest.getGlobal());
clearStack(function() {
done();

View File

@@ -940,8 +940,8 @@ describe("Env integration", function() {
env.addReporter(reporter);
jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL = 1290;
env.beforeAll(function(done) {
jasmine.clock().tick(1290);
env.beforeAll(function(innerDone) {
jasmine.clock().tick(1291);
});
env.it("spec that will be failed", function() {
@@ -981,6 +981,7 @@ describe("Env integration", function() {
clock.tick(6);
expect(true).toEqual(true);
innerDone();
jasmine.clock().tick(1);
});
env.execute();
@@ -1007,10 +1008,12 @@ describe("Env integration", function() {
env.afterAll(function(innerDone) {
jasmine.clock().tick(3001);
innerDone();
jasmine.clock().tick(1);
});
});
env.execute();
jasmine.clock().tick(1);
});
it('should wait a custom interval before reporting async functions that fail to call done', function(done) {
@@ -1132,6 +1135,7 @@ describe("Env integration", function() {
innerDone();
}, 1);
jasmine.clock().tick(1);
jasmine.clock().tick(1);
});
env.it('specifies a message', function(innerDone) {
@@ -1140,6 +1144,7 @@ describe("Env integration", function() {
innerDone();
}, 1);
jasmine.clock().tick(1);
jasmine.clock().tick(1);
});
env.it('fails via the done callback', function(innerDone) {
@@ -1147,6 +1152,7 @@ describe("Env integration", function() {
innerDone.fail('done failed');
}, 1);
jasmine.clock().tick(1);
jasmine.clock().tick(1);
});
env.it('has a message from an Error', function(innerDone) {
@@ -1155,6 +1161,7 @@ describe("Env integration", function() {
innerDone();
}, 1);
jasmine.clock().tick(1);
jasmine.clock().tick(1);
});
});

View File

@@ -21,13 +21,16 @@ getJasmineRequireObj().clearStack = function(j$) {
if (global && global.process && j$.isFunction_(global.process.nextTick)) {
return global.process.nextTick;
} else if (j$.isFunction_(global.setImmediate)) {
return global.setImmediate;
var realSetImmediate = global.setImmediate;
return function(fn) {
realSetImmediate(fn);
};
} else if (!j$.util.isUndefined(global.MessageChannel)) {
return messageChannelImpl(global);
} else if (j$.isFunction_(global.setTimeout)) {
} else {
var realSetTimeout = global.setTimeout;
return function clearStack(fn) {
realSetTimeout(fn, 0);
Function.prototype.apply.apply(realSetTimeout, [global, [fn, 0]]);
};
}
}