本文整理汇总了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();
}));