diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 514bc774..2bffc9cb 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -771,9 +771,9 @@ getJasmineRequireObj().Env = function(j$) { var totalSpecsDefined = 0; - var realSetTimeout = j$.getGlobal().setTimeout; - var realClearTimeout = j$.getGlobal().clearTimeout; - var clearStack = j$.getClearStack(j$.getGlobal()); + var realSetTimeout = global.setTimeout; + var realClearTimeout = global.clearTimeout; + var clearStack = j$.getClearStack(global); this.clock = new j$.Clock(global, function () { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global)); var runnableResources = {}; diff --git a/spec/core/integration/EnvSpec.js b/spec/core/integration/EnvSpec.js index 2d7c1caa..b4dd9d85 100644 --- a/spec/core/integration/EnvSpec.js +++ b/spec/core/integration/EnvSpec.js @@ -940,10 +940,10 @@ describe("Env integration", function() { }); it("Mock clock can be installed and used in tests", function(done) { - var globalSetTimeout = jasmine.createSpy('globalSetTimeout'), + var globalSetTimeout = jasmine.createSpy('globalSetTimeout').and.callFake(function(cb, t) { setTimeout(cb, t); }), delayedFunctionForGlobalClock = jasmine.createSpy('delayedFunctionForGlobalClock'), delayedFunctionForMockClock = jasmine.createSpy('delayedFunctionForMockClock'), - env = new jasmineUnderTest.Env({global: { setTimeout: globalSetTimeout }}); + env = new jasmineUnderTest.Env({global: { setTimeout: globalSetTimeout, clearTimeout: clearTimeout, setImmediate: function(cb) { setTimeout(cb, 0); } }}); var assertions = function() { expect(delayedFunctionForMockClock).toHaveBeenCalled(); @@ -1616,7 +1616,7 @@ describe("Env integration", function() { }); it("should be possible to get full name from a spec", function() { - var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}), + var env = new jasmineUnderTest.Env(), topLevelSpec, nestedSpec, doublyNestedSpec; env.describe("my tests", function() { @@ -1638,7 +1638,7 @@ describe("Env integration", function() { }); it("Custom equality testers should be per spec", function(done) { - var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}), + var env = new jasmineUnderTest.Env(), reporter = jasmine.createSpyObj('fakeReporter', [ "jasmineDone", "specDone" @@ -1672,7 +1672,7 @@ describe("Env integration", function() { }); it("Custom equality testers should be per suite", function(done) { - var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}), + var env = new jasmineUnderTest.Env(), reporter = jasmine.createSpyObj('fakeReporter', [ "jasmineDone", "specDone" @@ -1715,7 +1715,7 @@ describe("Env integration", function() { }); it("Custom equality testers for toContain should be per spec", function(done) { - var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}), + var env = new jasmineUnderTest.Env(), reporter = jasmine.createSpyObj('fakeReporter', [ "jasmineDone", "specDone" @@ -1766,7 +1766,7 @@ describe("Env integration", function() { }); it("Custom equality testers for toContain should be per suite", function(done) { - var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}), + var env = new jasmineUnderTest.Env(), reporter = jasmine.createSpyObj('fakeReporter', [ "jasmineDone", "specDone" @@ -1809,7 +1809,7 @@ describe("Env integration", function() { }); it("Custom matchers should be per spec", function(done) { - var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}), + var env = new jasmineUnderTest.Env(), matchers = { toFoo: function() {} }; @@ -1831,7 +1831,7 @@ describe("Env integration", function() { }); it("Custom matchers should be per suite", function(done) { - var env = new jasmineUnderTest.Env({global: { setTimeout: setTimeout }}), + var env = new jasmineUnderTest.Env(), matchers = { toFoo: function() {} }; diff --git a/src/core/Env.js b/src/core/Env.js index 4e110c42..74b31829 100644 --- a/src/core/Env.js +++ b/src/core/Env.js @@ -13,9 +13,9 @@ getJasmineRequireObj().Env = function(j$) { var totalSpecsDefined = 0; - var realSetTimeout = j$.getGlobal().setTimeout; - var realClearTimeout = j$.getGlobal().clearTimeout; - var clearStack = j$.getClearStack(j$.getGlobal()); + var realSetTimeout = global.setTimeout; + var realClearTimeout = global.clearTimeout; + var clearStack = j$.getClearStack(global); this.clock = new j$.Clock(global, function () { return new j$.DelayedFunctionScheduler(); }, new j$.MockDate(global)); var runnableResources = {};