Sha256: 862304247e0cd4b487c4071cc9600b61abdbb59de552d64e1c0998c60b10dfdb

Contents?: true

Size: 1 KB

Versions: 44

Compression:

Stored size: 1 KB

Contents

describe("MockClock", function () {

  beforeEach(function() {
    jasmine.Clock.useMock();    
  });

  describe("setTimeout", function () {
    it("should mock the clock when useMock is in a beforeEach", function() {
      var expected = false;
      setTimeout(function() {
        expected = true;
      }, 30000);
      expect(expected).toBe(false);
      jasmine.Clock.tick(30001);
      expect(expected).toBe(true);
    });
  });

  describe("setInterval", function () {
    it("should mock the clock when useMock is in a beforeEach", function() {
      var interval = 0;
      setInterval(function() {
        interval++;
      }, 30000);
      expect(interval).toEqual(0);
      jasmine.Clock.tick(30001);
      expect(interval).toEqual(1);
      jasmine.Clock.tick(30001);
      expect(interval).toEqual(2);
      jasmine.Clock.tick(1);
      expect(interval).toEqual(2);
    });
  });

  it("shouldn't complain if you call jasmine.Clock.useMock() more than once", function() {
    jasmine.Clock.useMock();
  });
});

Version data entries

44 entries across 44 versions & 9 rubygems

Version Path
evergreen-1.3.0 lib/jasmine/spec/core/MockClockSpec.js
evergreen-1.2.0 lib/jasmine/spec/core/MockClockSpec.js
evergreen-1.1.3 lib/jasmine/spec/core/MockClockSpec.js
evergreen-1.1.2 lib/jasmine/spec/core/MockClockSpec.js
evergreen-1.1.0 lib/jasmine/spec/core/MockClockSpec.js
rally-jasmine-core-1.2.0.3 ./lib/jasmine-core/spec/core/MockClockSpec.js
evergreen-1.0.1 lib/jasmine/spec/core/MockClockSpec.js
rally-jasmine-core-1.2.0.2 ./lib/jasmine-core/spec/core/MockClockSpec.js
jasmine-core-1.3.1 ./lib/jasmine-core/spec/core/MockClockSpec.js
jasmine-core-1.3.0 ./lib/jasmine-core/spec/core/MockClockSpec.js
rally-jasmine-core-1.2.0.1 ./lib/jasmine-core/spec/core/MockClockSpec.js
rally-jasmine-core-1.2.0.0 ./lib/jasmine-core/spec/core/MockClockSpec.js
jasmine-core-1.2.0 ./lib/jasmine-core/spec/core/MockClockSpec.js
jasmine-core-1.2.0.rc3 ./lib/jasmine-core/spec/core/MockClockSpec.js
jasmine-core-1.2.0.rc2 ./lib/jasmine-core/spec/core/MockClockSpec.js
evergreen-1.0.0 lib/jasmine/spec/core/MockClockSpec.js
evergreen-1.0.0.rc lib/jasmine/spec/suites/MockClockSpec.js
jasmine-core-1.2.0.rc1 ./lib/jasmine-core/spec/core/MockClockSpec.js
jasmine-core-1.1.0 ./lib/jasmine-core/spec/core/MockClockSpec.js
jasmine-core-1.1.0.rc4 ./lib/jasmine-core/spec/core/MockClockSpec.js