我正在开发一款具有火种卡功能的Ionic 2
应用。我想测试我的卡throwout
事件,当卡被拖动超过限制时发生。我正在使用https://www.nist.gov/pml/time-and-frequency-division/popular-links/daylight-saving-time-dst库。
home.html的
<div swing-stack #myswing1 [stackConfig]="stackConfig" id="card-stack">
<button ion-button icon-only *ngIf="hunts.length == 0" (click)="loadHunts()"><ion-icon name="refresh-circle"></ion-icon></button>
<ion-card swing-card #mycards1 *ngFor="let hunt of hunts" [navPush]="showHuntPage" [navParams]="{hunt: hunt}" >
<ion-card-header>
{{hunt.title}}
</ion-card-header>
<ion-card-content>
<div><img width="150" height="250" [src]="imageSource(hunt.picture_url)"></div>
<div>
{{hunt.clue}}
</div>
<div>
{{hunt.distance_from_user }} away
</div>
</ion-card-content>
</ion-card>
</div>
</ion-content>
通过拖动,每个ion-card
为throwable
。
我这样订阅throwing
中的home.ts
个活动。
this.throwRightSub = this.swingStack.throwoutright.subscribe( (event: ThrowEvent) => {
let hunt = this.hunts.shift();
this.reviewHunt("accepted",hunt);
this.events.publish("hunt-accepted",hunt);
});
this.throwLeftSub = this.swingStack.throwoutleft.subscribe( (event: ThrowEvent) => {
let hunt = this.hunts.shift();
this.reviewHunt("rejected",hunt);
});
}
我看到点击事件被嘲笑
let el = fixture.debugElement.query(By.css('ion-card'));
el.triggerEventHandler('click', null);
无论如何在单元测试中触发drag
事件?任何帮助,将不胜感激。