本文整理匯總了TypeScript中@angular/core/testing.discardPeriodicTasks函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript discardPeriodicTasks函數的具體用法?TypeScript discardPeriodicTasks怎麽用?TypeScript discardPeriodicTasks使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了discardPeriodicTasks函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: fakeAsync
fakeAsync(() => {
const html = `
<carousel [keyboard]="keyboard">
<slide>slide1</slide>
<slide>slide2</slide>
</carousel>
`;
const fixture = createTestComponent(html);
expectActiveSlides(fixture.nativeElement, [true, false]);
fixture.componentInstance.keyboard = false;
fixture.detectChanges();
fixture.debugElement
.query(By.directive(CarouselComponent))
.triggerEventHandler('keydown.arrowRight', {}); // prev()
fixture.detectChanges();
expectActiveSlides(fixture.nativeElement, [true, false]);
fixture.componentInstance.keyboard = true;
fixture.detectChanges();
fixture.debugElement
.query(By.directive(CarouselComponent))
.triggerEventHandler('keydown.arrowRight', {}); // next()
fixture.detectChanges();
expectActiveSlides(fixture.nativeElement, [false, true]);
discardPeriodicTasks();
})
示例2: it
it('should fetch HTTP endpoint once and only once', fakeAsync(() => {
const mockFeatureTogglesMap = [
{
rbd: true,
mirroring: true,
iscsi: true,
cephfs: true,
rgw: true
}
];
service
.get()
.subscribe((featureTogglesMap) => expect(featureTogglesMap).toEqual(mockFeatureTogglesMap));
tick();
// Second subscription shouldn't trigger a new HTTP request
service
.get()
.subscribe((featureTogglesMap) => expect(featureTogglesMap).toEqual(mockFeatureTogglesMap));
const req = httpTesting.expectOne(service.API_URL);
req.flush(mockFeatureTogglesMap);
discardPeriodicTasks();
}));
示例3: it
it('should not wrap slide changes by when requested', fakeAsync(() => {
const html = `
<carousel [noWrap]="true">
<slide>slide1</slide>
<slide>slide2</slide>
</carousel>
`;
const fixture = createTestComponent(html);
const controlElms = fixture.nativeElement.querySelectorAll('.carousel-control');
expectActiveSlides(fixture.nativeElement, [true, false]);
controlElms[0].click(); // prev
fixture.detectChanges();
expectActiveSlides(fixture.nativeElement, [true, false]);
controlElms[1].click(); // next
fixture.detectChanges();
expectActiveSlides(fixture.nativeElement, [false, true]);
controlElms[1].click(); // next
fixture.detectChanges();
expectActiveSlides(fixture.nativeElement, [false, true]);
discardPeriodicTasks();
}));
示例4: fakeAsync
fakeAsync(() => {
const mockMessage = {
items: [
{
id: 1,
authorDetails: { displayName: 'Kevin' },
snippet: { type: 'textMessageEvent', displayMessage: 'test' }
},
{
id: 2,
authorDetails: { displayName: 'Kevin' },
snippet: { type: 'superChatEvent', displayMessage: 'test' }
}
]
};
spyOn(service, 'queryLiveChat').and.returnValue(of(mockMessage));
service.messages$.subscribe(message => {
expect(message).toEqual([
{
id: 1,
displayName: 'Kevin',
displayMessage: 'test'
},
{
id: 2,
displayName: 'Kevin',
displayMessage: 'test'
}
]);
});
service['pollingIntervalMillis$'].next(100);
tick(100);
discardPeriodicTasks();
})
示例5: fakeAsync
+ '\'TEXT\'. And dispatch NoteSnippetEditorInsertImageEvent when user select file.', fakeAsync(() => {
const selectedNote = noteDummy.create();
const content = contentDummy.create();
content.snippets[0] = new NoteSnippetContentDummy().create(NoteSnippetTypes.TEXT);
ensureSelectNoteAndLoadNoteContent(selectedNote, content);
activateSnippetAtIndex(0);
fixture.detectChanges();
spyOn(nativeDialog, 'showOpenDialog').and.returnValue(of({
isSelected: true,
filePaths: ['/foo/bar/assets/some-image.png'],
} as NativeDialogOpenResult));
spyOn(noteEditor, 'copyAssetFile').and.returnValue(of({
fileNameWithoutExtension: 'some-image',
relativePathToWorkspaceDir: './some-image.png',
} as Asset));
menuMessages.next(MenuEvent.INSERT_IMAGE);
flush();
flush();
flush();
expect(nativeDialog.showOpenDialog).toHaveBeenCalledWith({
message: 'Choose an image:',
properties: NativeDialogProperties.OPEN_FILE,
fileFilters: [nativeDialogFileFilters.IMAGES],
} as NativeDialogConfig);
expect(noteEditor.copyAssetFile).toHaveBeenCalledWith(
AssetTypes.IMAGE,
selectedNote.contentFilePath,
'/foo/bar/assets/some-image.png',
);
expect(listManager.handleSnippetRefEvent).toHaveBeenCalled();
const event = (
listManager.handleSnippetRefEvent as Spy
).calls.first().args[0] as NoteSnippetEditorInsertImageEvent;
// noinspection SuspiciousInstanceOfGuard
expect(event instanceof NoteSnippetEditorInsertImageEvent).toBe(true);
expect(event.payload.fileName).toEqual('some-image');
expect(event.payload.filePath).toEqual('./some-image.png');
discardPeriodicTasks();
}));