Skip to content

Commit

Permalink
Added test for annotations' visibility via position skipping. #36
Browse files Browse the repository at this point in the history
  • Loading branch information
pisi committed Dec 29, 2011
1 parent 193fd81 commit ccc1cfd
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/unit/annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,57 @@
});
});

asyncTest( 'Visibility via position skipping', function(){
expect( 6 );
var
frames= 6,
xs= [ 10, 20, undefined, 30, , 20 ],
ys= [ 20, undefined, 10, 0 , 40, ],
$reel= $('#image').reel({ frames: frames, speed: 1, annotations: {
'xy-positioned-annotation': {
x: xs,
y: ys
}
}})

$reel.parent().bind('frameChange.test', function(){
var
frame= $reel.data('frame'),
index= frame - 1

if (index < 0) return;

equiv( $('#xy-positioned-annotation').css('display'), xs[index] === undefined || ys[index] === undefined ? 'none':'block', 'visibility @ frame '+frame);
if (index >= xs.length-1) start();
});
});

asyncTest( 'Visibility via position skipping with one fixed axis (works for the other too)', function(){
expect( 8 );
var
frames= 6,
xs= [ 10, 20, 30, 20 ],
y= 30,
$reel= $('#image').reel({ frames: frames, speed: 1, annotations: {
'xy-positioned-annotation': {
x: xs,
y: y
}
}})

$reel.parent().bind('frameChange.test', function(){
var
frame= $reel.data('frame'),
index= frame - 1

if (index < 0) return;

equiv( $('#xy-positioned-annotation').css('left'), xs[index], 'x @ frame '+frame);
equiv( $('#xy-positioned-annotation').css('top'), y, 'y @ frame '+frame);
if (index >= xs.length-1) start();
});
});

asyncTest( 'Visibility switching with `at`', function(){
expect( 6 );
var
Expand Down

0 comments on commit ccc1cfd

Please sign in to comment.