8 describe('Fx', function(){
10 beforeEach(function(){
11 this.clock = sinon.useFakeTimers();
19 Object.each(Fx.Transitions, function(value, transition){
20 if (transition == 'extend') return;
22 it('should start a Fx and call the onComplete event with ' + transition + ' as timing function', function(){
24 var onComplete = sinon.spy(),
25 onStart = sinon.spy();
29 transition: Fx.Transitions[transition],
30 onComplete: onComplete,
34 expect(onStart.called).to.equal(false);
39 expect(onStart.called).to.equal(true);
40 expect(onComplete.called).to.equal(false);
42 this.clock.tick(1000);
43 expect(onComplete.called).to.equal(true);
48 it('should cancel a Fx', function(){
50 var onCancel = sinon.spy();
54 transition: 'sine:in:out',
60 expect(onCancel.called).to.equal(false);
64 expect(onCancel.called).to.equal(true);
68 it('should set the computed value', function(){
70 var FxLog = new Class({
72 set: function(current){
81 this.clock.tick(2000);
83 expect(fx.foo).to.equal(10);
87 it('should pause and resume', function(){
89 var FxLog = new Class({
91 set: function(current){
100 this.clock.tick(1000);
106 expect(fx.foo).to.be.greaterThan(0);
107 expect(fx.foo).to.be.lessThan(1);
109 this.clock.tick(1000);
111 expect(fx.foo).to.equal(value);
114 this.clock.tick(2000);
116 expect(fx.foo).to.equal(1);
120 it('should chain the Fx', function(){
125 onComplete: function(){
133 this.clock.tick(1000);
134 this.clock.tick(1000);
136 expect(counter).to.equal(2);
139 it('should cancel the Fx after a new Fx:start with the link = cancel option', function(){
141 var onCancel = sinon.spy();
151 this.clock.tick(1000);
153 expect(onCancel.called).to.equal(true);
159 describe('Fx', function(){
161 beforeEach(function(){
162 this.clock = sinon.useFakeTimers();
165 afterEach(function(){
167 this.clock.restore();
170 it('should return the paused state', function(){
175 expect(fx.isPaused()).to.equal(false);
177 this.clock.tick(300);
180 expect(fx.isPaused()).to.equal(true);
183 this.clock.tick(600);
184 expect(fx.isPaused()).to.equal(false);