reduces posibility of race condition
This commit is contained in:
parent
b3c8cd76c6
commit
e46de301f5
@ -4,17 +4,17 @@ require('phantomjs-polyfill');
|
|||||||
|
|
||||||
test('time moves', function(assert) {
|
test('time moves', function(assert) {
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
animator.start();
|
animator.start();
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
assert.notEqual(animator._time, 0);
|
assert.notEqual(animator._time, 0);
|
||||||
done();
|
done();
|
||||||
}, 100)
|
}, 20)
|
||||||
animator.pause();
|
animator.pause();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("rescale should resume animation if previously playing", function(assert){
|
test("rescale should resume animation if previously playing", function(assert){
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
animator.toggle();
|
animator.toggle();
|
||||||
animator.rescale();
|
animator.rescale();
|
||||||
assert.ok(animator.running);
|
assert.ok(animator.running);
|
||||||
@ -22,14 +22,14 @@ test("rescale should resume animation if previously playing", function(assert){
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("rescale shouldn't resume animation if previously paused", function(assert){
|
test("rescale shouldn't resume animation if previously paused", function(assert){
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
animator.pause();
|
animator.pause();
|
||||||
animator.rescale();
|
animator.rescale();
|
||||||
assert.notOk(animator.running);
|
assert.notOk(animator.running);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("onStart runs properly", function(assert){
|
test("onStart runs properly", function(assert){
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
animator.options.onStop = function(){
|
animator.options.onStop = function(){
|
||||||
assert.ok(true);
|
assert.ok(true);
|
||||||
animator.pause();
|
animator.pause();
|
||||||
@ -38,13 +38,13 @@ test("onStart runs properly", function(assert){
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("stop should take the pointer to position zero", function(assert){
|
test("stop should take the pointer to position zero", function(assert){
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
animator.stop()
|
animator.stop()
|
||||||
assert.equal(animator._time, 0);
|
assert.equal(animator._time, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("stop should call onStop", function(assert){
|
test("stop should call onStop", function(assert){
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
animator.options.onStop = function(){
|
animator.options.onStop = function(){
|
||||||
assert.ok(true);
|
assert.ok(true);
|
||||||
animator.pause();
|
animator.pause();
|
||||||
@ -53,7 +53,7 @@ test("stop should call onStop", function(assert){
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("altering steps should rescale", function(assert){
|
test("altering steps should rescale", function(assert){
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
sinon.spy(animator, "rescale");
|
sinon.spy(animator, "rescale");
|
||||||
animator.steps(600);
|
animator.steps(600);
|
||||||
assert.ok(animator.rescale.calledOnce);
|
assert.ok(animator.rescale.calledOnce);
|
||||||
@ -61,19 +61,19 @@ test("altering steps should rescale", function(assert){
|
|||||||
|
|
||||||
test("tick should set time to zero if steps are bigger than range", function(assert){
|
test("tick should set time to zero if steps are bigger than range", function(assert){
|
||||||
var done = assert.async();
|
var done = assert.async();
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
animator.start();
|
animator.start();
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
animator._time = 0;
|
animator._time = 0;
|
||||||
animator.step(800);
|
animator.step(800);
|
||||||
assert.ok(animator.step() < 800);
|
assert.ok(animator.step() < 800);
|
||||||
done();
|
done();
|
||||||
}, 200);
|
}, 20);
|
||||||
animator.pause();
|
animator.pause();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("tick should pause animation on end if loop is disabled", function(assert){
|
test("tick should pause animation on end if loop is disabled", function(assert){
|
||||||
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 10});
|
var animator = new torque.Animator(function(){}, {steps: 500, animationDuration: 2});
|
||||||
animator.options.loop = false;
|
animator.options.loop = false;
|
||||||
animator.toggle();
|
animator.toggle();
|
||||||
animator.step(600);
|
animator.step(600);
|
||||||
|
Loading…
Reference in New Issue
Block a user