本文整理汇总了TypeScript中simulant.fire函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fire函数的具体用法?TypeScript fire怎么用?TypeScript fire使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fire函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should support selecting the document element', function(done) {
function app(_sources: {DOM: MainDOMSource}) {
return {
DOM: xs.of(div('hello world')),
};
}
const {sinks, sources, run} = setup(app, {
DOM: makeDOMDriver(createRenderTarget()),
});
function isDocument(element: any): element is Document {
return 'body' in element && 'head' in element;
}
let dispose: any;
sources.DOM.select('document')
.events('click')
.take(1)
.addListener({
next: (event: Event) => {
assert(isDocument(event.target));
setTimeout(() => {
dispose();
done();
});
},
});
dispose = run();
simulant.fire(document, 'click');
});
示例2: it
it('checks input sends message on enter with text input value', async(inject([ChatRoomService], (chatRoomServiceMock: ChatRoomServiceMock) => {
chatRoomServiceMock.connected$.next(true);
fixture.detectChanges();
let input = fixture.debugElement.query(By.css('input')).nativeElement;
input.value = 'test';
fixture.detectChanges();
let event = simulant('keyup', {key: 'enter', code: 13, keyCode: 13});
simulant.fire(input, event);
fixture.detectChanges();
expect(chatRoomServiceMock.send).toHaveBeenCalledWith('test');
})));