diff --git a/spec/core/EnvSpec.js b/spec/core/EnvSpec.js index 09d32453..2f429983 100644 --- a/spec/core/EnvSpec.js +++ b/spec/core/EnvSpec.js @@ -293,52 +293,33 @@ describe("Env integration", function() { }); describe("with a mock clock", function() { - beforeEach(function() { - jasmine.getEnv().clock.install(); + beforeEach(function() { + jasmine.getEnv().clock.install(); + }); + + afterEach(function() { + jasmine.getEnv().clock.uninstall(); + }); + + it("should not hang on async specs that forget to call done()", function(done) { + var env = new j$.Env(), + reporter = jasmine.createSpyObj('fakeReporter', [ "specDone" ]); + + reporter.specDone.and.callFake(function() { + expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'failed'})); + done(); }); - afterEach(function() { - jasmine.getEnv().clock.uninstall(); + env.addReporter(reporter); + + env.it("async spec that will hang", function(underTestCallback) { + env.expect(true).toBeTruthy(); + jasmine.getEnv().clock.tick(10000); + jasmine.getEnv().clock.tick(1); // trigger specDone callback }); - it("should not hang on async specs that forget to call done()", function(done) { - var env = new j$.Env(), - reporter = jasmine.createSpyObj('fakeReporter', [ - "jasmineStarted", - "jasmineDone", - "suiteStarted", - "suiteDone", - "specStarted", - "specDone" - ]); - - env.addReporter(reporter); - - env.describe("tests", function() { - env.it("async spec that will hang", function(underTestCallback) { - env.expect(true).toBeTruthy(); - }); - - env.it("after async spec", function() { - env.expect(true).toBeTruthy(); - }); - }); - - env.execute(); - - reporter.jasmineDone.and.callFake(function() { - expect(reporter.jasmineStarted).toHaveBeenCalledWith({ - totalSpecsDefined: 2 - }); - - expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'passed'})); - expect(reporter.specDone).toHaveBeenCalledWith(jasmine.objectContaining({status: 'failed'})); - - done(); - }); - - jasmine.getEnv().clock.tick(60001); - }); + env.execute(); + }); }); // TODO: something is wrong with this spec