本文整理匯總了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');
})));