cjohansen/Sinon.JS — Issue #81: Dependency between tests using jQuery .animation with Duration
Author: victormartins
Created: 2012-02-02 16:18:31+00:00
State: open

I'm having a hard time testing animation tests and I think I boiled the problem to a dependency issue.

It seems that if we add the duration to the animation, the following tests are affected. In the following example both tests fail because of the 1000 duration value on the first test. But if I remove that value, both tests pass.

describe("Test animation with duration", function(){

beforeEach(function(){
this.clock = sinon.useFakeTimers();
});

afterEach(function (){
this.clock.restore();
});

it("test should animate element over 1000ms", function(){
var el = $("

");
el.appendTo(document.body);

el.animate({ height: "300px", width: "200px" },1000); // Notice the duration
this.clock.tick(510);
expect(el.css("height")).toBe("300px");
expect(el.css("width")).toBe("200px");
});

it("test should animate element over 500ms", function(){
var el = $("

");
el.appendTo(document.body);

el.animate({ height: "300px", width: "200px" });
this.clock.tick(510);
expect(el.css("height")).toBe("300px");
expect(el.css("width")).toBe("200px");
});

});