如何为角度动画制作测试用例



我使用 karma 编写 angular2 测试用例,但不知道如何测试动画。我试图获取并检查主机元素的转换属性,但得到"无","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();
}

我想我找到了一个例子

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}
]);
});

最新更新