Skip to content

Commit

Permalink
test existance of animation methods and failure to create animation w…
Browse files Browse the repository at this point in the history
…ithout options object. Abacus#56
  • Loading branch information
mzgoddard committed Oct 20, 2011
1 parent 9bd692c commit a6ca716
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/unit/abacus.animation.js
Expand Up @@ -6,6 +6,32 @@ test('animation defined functions exists', 3, function() {
ok( Abacus.animation.frame, 'animation.frame exists' );
});

test('animation methods', 5, function() {
var animation = Abacus.animation({});

ok( animation.reset, 'animation.reset exists' );
ok( animation.start, 'animation.start exists' );
ok( animation.stop, 'animation.stop exists' );
ok( animation.addLayer, 'animation.addLayer exists' );
ok( animation.layer, 'animation.layer exists' );
});

test('layer methods', 5, function() {
var layer = Abacus.animation.layer();

ok( layer.reset, 'layer.reset exists' );
ok( layer.step, 'layer.step exists' );
ok( layer.addFrame, 'layer.addFrame exists' );
ok( layer.removeFrame, 'layer.removeFrame exists' );
ok( layer.getFrame, 'layer.getFrame exists' );
});

test('animation() fails', 1, function() {
raises(function() {
Abacus.animation();
}, 'animation() cannot be called without options object');
});

test('layer.step updates values', 2, function() {
var position = [0, 0],
layer = Abacus.animation.layer({
Expand Down Expand Up @@ -100,7 +126,7 @@ asyncTest('animation stops timer after completion', 3, function() {

setTimeout(function() {
ok( timePlayed > 1000/6, 'timePlayed (' + timePlayed + ') > ' + Math.floor(1000/6) );
equal( animation.layers[0].frameIndex, -1, 'reached end of frames' );
equal( animation.layers[0].frameIndex, -1, 'auto-reset to start of animatio' );
ok( animation.timer.isPaused );
if ( !animation.timer.isPaused ) {
animation.timer.pause();
Expand Down

0 comments on commit a6ca716

Please sign in to comment.