【发布时间】:2018-07-20 23:06:53
【问题描述】:
我的 Angular 5 组件使用typeahead directive of ngx-bootstrap,如下所示:
<input [(ngModel)]="inputted"
[typeahead]="days"
(typeaheadOnSelect)="select($event)"
class="form-control">
现在我想测试当用户在预输入中选择一个项目时我的组件是否符合预期。我需要模拟 typeahead 指令的 typeaheadOnSelect 输出。如何在我的单元测试中访问指令,手动发出 typeaheadOnSelect 事件?到目前为止,我已经走到了这一步:
const elem: DebugElement = fixture.debugElement.query(By.css('input'));
这给了我输入元素。如何从那里找到底层的 typeahead 指令?
【问题讨论】:
标签: angular unit-testing angular5