Passing arguments to setInterval and setTimeout callbacks #283

Closed
wants to merge 1 commit into
from
View
@@ -1,7 +1,7 @@
describe("MockClock", function () {
beforeEach(function() {
- jasmine.Clock.useMock();
+ jasmine.Clock.useMock();
});
describe("setTimeout", function () {
@@ -14,6 +14,17 @@ describe("MockClock", function () {
jasmine.Clock.tick(30001);
expect(expected).toBe(true);
});
+
+ it('should pass the specified arguments to the callback', function() {
+ var aUnicorn = "a unicorn";
+ var expectItToBeAUnicorn = function() {
+ expect(arguments.length).toEqual(1);
+ expect(arguments[0]).toBe(aUnicorn);
+ };
+
+ setTimeout(expectItToBeAUnicorn, 0, aUnicorn);
+ jasmine.Clock.tick(0);
+ });
});
describe("setInterval", function () {
@@ -30,6 +41,17 @@ describe("MockClock", function () {
jasmine.Clock.tick(1);
expect(interval).toEqual(2);
});
+
+ it('should pass the specified arguments to the callback', function() {
+ var aUnicorn = "a unicorn";
+ var expectItToBeAUnicorn = function() {
+ expect(arguments.length).toEqual(1);
+ expect(arguments[0]).toBe(aUnicorn);
+ };
+
+ setInterval(expectItToBeAUnicorn, 0, aUnicorn);
+ jasmine.Clock.tick(0);
+ });
});
it("shouldn't complain if you call jasmine.Clock.useMock() more than once", function() {