[英]Testing hammerjs events with angular2
I'm building a testing suite and try to cover 100% of the code. 我正在构建一个测试套件,并尝试覆盖100%的代码。 Thing is, I have callback functions on panning.
事情是,我有关于平移的回调函数。 Does anyone how to correctly test hammerjs events with karma & jasmine on angular2 ?
有没有人如何在angular2上使用karma和jasmine正确测试hammerjs事件?
HTML HTML
<div (pan)="panning($event)" id="square">
TypeScript 打字稿
public swiper($event) {
let e = $event;
let top = e.center.x - (e.target.clientHeight/2);
let left = e.center.y - (e.target.clientWidth/2);
e.target.style.transform = 'translate3d('+ top +'px, '+ left +'px, 0px)';
}
Thank you. 谢谢。
M 中号
You should be able to use this : 你应该可以使用这个 :
it('should call panning on pan', (async() => {
fixture.debugElement.query(By.css('#square')).triggerEventHandler("pan", myNiceEvent)
fixture.detectChanges()
fixture.whenStable().then(testMyChanges)
}
I know it's been a long time, but I've struggled with that for Angular v5.2.0 myself. 我知道这已经很长时间了,但我自己也为Angular v5.2.0做了很多努力。
Hoping this will help someone ;) 希望这会帮助某人;)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.