本文整理汇总了TypeScript中angular2/testing_internal.dispatchEvent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript dispatchEvent函数的具体用法?TypeScript dispatchEvent怎么用?TypeScript dispatchEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dispatchEvent函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: dispatchEvent
tcb.createAsync(DemoFormWithEvents).then((fixture) => {
let el = fixture.debugElement.nativeElement;
let input = fixture.debugElement.query(By.css("input")).nativeElement;
let form = fixture.debugElement.query(By.css("form")).nativeElement;
fixture.detectChanges();
input.value = '';
dispatchEvent(input, 'input');
fixture.detectChanges();
tick();
// no value on sku field, all error messages are displayed
let msgs = el.querySelectorAll('.ui.error.message');
expect(msgs[0]).toHaveText('SKU is invalid');
expect(msgs[1]).toHaveText('SKU is required');
// displays no errors when sku has a value
input.value = 'XYZ';
dispatchEvent(input, 'input');
fixture.detectChanges();
tick()
msgs = el.querySelectorAll('.ui.error.message');
expect(msgs.length).toEqual(0);
fixture.detectChanges();
dispatchEvent(form, 'submit');
tick();
// checks for the form submitted message
expect(fakeConsole._logs).toContain('you submitted value: XYZ');
});
开发者ID:Gitjerryzhong,项目名称:angular2,代码行数:32,代码来源:demo_form_with_events_bad.spec.ts
示例2: createComponent
createComponent(tcb).then((fixture: ComponentFixture) => {
usernameInput.value = 'barretodavid';
emailInput.value = '[email protected]';
dispatchEvent(usernameInput, 'input');
dispatchEvent(emailInput, 'input');
tick();
let data = element.querySelector('.submit-data');
expect(data).toHaveText('Value to submit: barretodavid, [email protected]')
});
开发者ID:aneagoie,项目名称:angular2-unit-test-app,代码行数:9,代码来源:create-user.component.spec.ts
示例3: createComponent
createComponent(tcb).then((fixture) => {
input.value = 'ABC';
dispatchEvent(input, 'input');
tick();
fixture.detectChanges();
dispatchEvent(form, 'submit');
tick();
expect(fakeConsole._logs).toContain('you submitted value: ABC');
});
开发者ID:Gitjerryzhong,项目名称:angular2,代码行数:11,代码来源:demo_form_with_events.spec.ts
示例4: createComponent
return createComponent(tcb).then((fixture) => {
input.value = '';
dispatchEvent(input, 'input');
fixture.detectChanges();
let msgs = el.querySelectorAll('.ui.error.message');
expect(msgs[0]).toHaveText('SKU is invalid');
expect(msgs[1]).toHaveText('SKU is required');
});
开发者ID:Gitjerryzhong,项目名称:angular2,代码行数:9,代码来源:demo_form_with_validations_explicit.spec.ts
注:本文中的angular2/testing_internal.dispatchEvent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论