Reputation: 93
I use karma to write angular2 test cases, but have no idea how to test animations. I tried to get and check the transform attributes of host element, but got 'none', neither the 'getCalculateStyle()' method can work. Any suggestions?
Example code to test:
func2Test() {
const animations: AnimationMetadata[] = [animate('500ms ease-in', style({transform: `translate3d(100px, 0px, 0px)`}))];
const myAnimation: AnimationFactory = this.animationBuilder.build(animations);
const player = myAnimation.create(this.slickTrack.nativeElement);
player.play();
}
Upvotes: 2
Views: 5660
Reputation: 93
I think i find an example
it('should fill in missing starting steps when a starting `style()` value is not used',
() => {
const steps = [animate(1000, style({width: 999}))];
const players = invokeAnimationSequence(rootElement, steps);
expect(players[0].keyframes).toEqual([
{width: AUTO_STYLE, offset: 0}, {width: 999, offset: 1}
]);
});
Upvotes: 1