【发布时间】:2021-07-30 11:32:56
【问题描述】:
我正在阅读来自here 的角度路由测试的官方示例。我不明白heroClick() 是如何触发点击的。
it('should tell ROUTER to navigate when hero clicked', () => {
heroClick(); <------- how does this work !? // trigger click on first inner <div class="hero">
// args passed to router.navigateByUrl() spy
const spy = router.navigateByUrl as jasmine.Spy;
const navArgs = spy.calls.first().args[0];
// expecting to navigate to id of the component's first hero
const id = comp.heroes[0].id;
expect(navArgs).toBe('/heroes/' + id, 'should nav to HeroDetail for first hero');
});
这是 stackblitz 示例的link
【问题讨论】:
标签: jasmine angular-test