如何制作角动画的测试用例

问题描述 投票:1回答:1

我使用业力来编写angular2测试用例,但不知道如何测试动画。我试图获取并检查host元素的transform属性,但得到'none','getCalculateStyle()'方法都不起作用。有什么建议?

要测试的示例代码:

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();
}
angular animation jasmine karma-jasmine angular-animations
1个回答
1
投票

我想我找到了一个例子

https://github.com/angular/angular/blob/master/packages/animations/browser/test/dsl/animation_spec.ts

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}
             ]);
           });
© www.soinside.com 2019 - 2024. All rights reserved.