• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

TypeScript testing.flush函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@angular/core/testing.flush函数的典型用法代码示例。如果您正苦于以下问题:TypeScript flush函数的具体用法?TypeScript flush怎么用?TypeScript flush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了flush函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: flush

 fixture.ngZone.run(() => {
   router = TestBed.get(Router);
   router.initialNavigation();
   // Generate breadcrumb items.
   router.navigate([ 'one', 'two', 'three', 'four' ]);
   fixture.detectChanges();
   flush();
   fixture.detectChanges();
   items = fixture.debugElement.queryAll(By.directive(NzBreadCrumbItemComponent));
   // Should generate 2 breadcrumbs when reaching out of the `data` scope.
   expect(breadcrumb.componentInstance.breadcrumbs.length).toBe(2);
   dispatchMouseEvent(items[ 1 ].nativeElement.querySelector('a'), 'click');
   router.navigate([ 'one', 'two', 'three' ]);
   fixture.detectChanges();
   flush();
   fixture.detectChanges();
   expect(breadcrumb.componentInstance.breadcrumbs.length).toBe(2);
   router.navigate([ 'one', 'two' ]);
   fixture.detectChanges();
   flush();
   fixture.detectChanges();
   expect(breadcrumb.componentInstance.breadcrumbs.length).toBe(1);
   router.navigate([ 'one' ]);
   fixture.detectChanges();
   flush();
   fixture.detectChanges();
   // Shouldn't generate breadcrumb at all.
   expect(breadcrumb.componentInstance.breadcrumbs.length).toBe(0);
 });
开发者ID:SrgGs,项目名称:ng-zorro-antd,代码行数:29,代码来源:nz-breadcrumb.spec.ts


示例2: it

    it('should create site when form is valid', fakeAsync(() => {
        findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse));
        spyOn(alfrescoApi.sitesApi, 'createSite').and.returnValue(
            Promise.resolve()
        );
        spyOn(alfrescoApi.sitesApi, 'getSite').and.callFake(() => {
            return new Promise((resolve, reject) => reject());
        });

        fixture.detectChanges();
        component.form.controls.title.setValue('library title');
        tick(500);
        flush();
        fixture.detectChanges();

        component.submit();
        fixture.detectChanges();
        flush();

        expect(alfrescoApi.sitesApi.createSite).toHaveBeenCalledWith({
            id: 'library-title',
            title: 'library title',
            description: '',
            visibility: 'PUBLIC'
        });
    }));
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:26,代码来源:library.dialog.spec.ts


示例3: fakeAsync

            + 'sync repository. When confirmed, open settings dialog.', fakeAsync(() => {
            (vcs.canSyncRepository as Spy).and.returnValue(Promise.resolve(false));

            getSyncWorkspaceButtonEl().click();
            flush();

            const confirmDialog = mockDialog.getByComponent<ConfirmDialogComponent,
                ConfirmDialogData,
                boolean>(
                ConfirmDialogComponent,
            );

            expect(confirmDialog).toBeDefined();
            expect(confirmDialog.config.data.isAlert).toBe(false);

            confirmDialog.close(true);
            flush();

            const settingsDialog = mockDialog.getByComponent<SettingsDialogComponent,
                SettingsDialogData,
                void>(
                SettingsDialogComponent,
            );

            expect(settingsDialog).toBeDefined();
            expect(settingsDialog.config.data.initialSettingId).toEqual(VCS_SETTINGS_ID);
        }));
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:27,代码来源:vcs-manager.component.spec.ts


示例4: it

 it('should throw error and redirect user if he has not logged in', fakeAsync(() => {
   spyOn(dashboardService, 'getProgressStatus').and.returnValue(throwError({error: 'ERROR'}));
   spyOn(languageService, 'loadLanguage').and.returnValue(Observable.of(languageData));
   flush();
   component.ngOnInit();
   fixture.detectChanges();
   flush();
   expect(router.navigate).toHaveBeenCalledWith(['/login']);
 }));
开发者ID:systers,项目名称:PC-Prep-Kit,代码行数:9,代码来源:menu.component.spec.ts


示例5: it

    it("reacts to save click", fakeAsync(() => {
      component.ngOnInit();
      component.click();
      httpAction.next({ url: '', method: HttpMethod.Post, isComplete: false });
      flush();
      expect(component.isSaving).toBeTruthy();

      httpAction.next({ url: '', method: HttpMethod.Post, isComplete: true });
      flush();
      expect(component.isSaving).toBeFalsy();
      expect(component.isListening).toBeFalsy();
    }));
开发者ID:OysteinAmundsen,项目名称:gymsystems,代码行数:12,代码来源:save-button.component.spec.ts


示例6: 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();
        }));
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:50,代码来源:note-editor.component.spec.ts


示例7: it

        it('should open alert when \'VcsPrimaryEmailNotExists\' exception thrown.', fakeAsync(() => {
            makeAccountsToBeLoadedWith();

            fixture.detectChanges();
            flush();
            fixture.detectChanges();

            switchAuthMethodOption(VcsAuthenticationTypes.OAUTH2_TOKEN);

            typeInElement('token', getTokenInputEl());
            fixture.detectChanges();

            const newAccount: VcsAccount = {
                ...vcsAccountDummy.create(VcsAuthenticationTypes.OAUTH2_TOKEN),
                email: null,
            };

            spyOn(github, 'authorizeByOauth2Token').and.returnValue(of(newAccount));
            spyOn(github, 'getPrimaryEmail').and.returnValue(throwError(new VcsPrimaryEmailNotExistsError()));

            getLoginAndAddAccountButtonEl().click();
            fixture.detectChanges();

            const alert = thisMockDialog.getByComponent<ConfirmDialogComponent,
                ConfirmDialogData,
                boolean>(
                ConfirmDialogComponent,
            );

            expect(alert).toBeDefined();
            expect(alert.config.data.title).toEqual('Cannot read email from github.com');
            expect(alert.config.data.isAlert).toEqual(true);
        }));
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:33,代码来源:github-accounts-dialog.component.spec.ts


示例8: fakeAsync

            + 'should reset form.', fakeAsync(() => {
            makeAccountsToBeLoadedWith();

            fixture.detectChanges();
            flush();
            fixture.detectChanges();

            switchAuthMethodOption(VcsAuthenticationTypes.OAUTH2_TOKEN);

            typeInElement('token', getTokenInputEl());
            fixture.detectChanges();

            const newAccount = vcsAccountDummy.create(VcsAuthenticationTypes.OAUTH2_TOKEN);

            spyOn(github, 'authorizeByOauth2Token').and.returnValue(of(newAccount));
            spyOn(accountDB, 'addNewAccount').and.callThrough();

            getLoginAndAddAccountButtonEl().click();
            fixture.detectChanges();

            expect(github.authorizeByOauth2Token).toHaveBeenCalledWith('token');
            expect(accountDB.addNewAccount).toHaveBeenCalledWith(newAccount);

            // Should form reset
            expect(component.addAccountFormGroup.value).toEqual({
                type: VcsAuthenticationTypes.OAUTH2_TOKEN,
                userName: '',
                password: '',
                token: '',
            });
        }));
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:31,代码来源:github-accounts-dialog.component.spec.ts


示例9: it

 it('should disable the tooltip', fakeAsync(() => {
   const fixture: ComponentFixture<
     CalendarMonthViewComponent
   > = TestBed.createComponent(CalendarMonthViewComponent);
   eventTitle.monthTooltip = () => '';
   fixture.componentInstance.viewDate = new Date('2016-06-27');
   fixture.componentInstance.events = [
     {
       start: new Date('2016-05-30'),
       end: new Date('2016-06-02'),
       title: 'foo <b>bar</b>',
       color: {
         primary: 'blue',
         secondary: 'rgb(238, 238, 238)'
       }
     }
   ];
   fixture.componentInstance.ngOnChanges({ viewDate: {}, events: {} });
   fixture.detectChanges();
   const event: HTMLElement = fixture.nativeElement.querySelector(
     '.cal-days .cal-cell-row .cal-cell:nth-child(4) .cal-events .cal-event'
   );
   triggerDomEvent('mouseenter', event);
   fixture.detectChanges();
   flush();
   expect(!!document.body.querySelector('.cal-tooltip')).to.equal(false);
 }));
开发者ID:mattlewis92,项目名称:angular2-calendar,代码行数:27,代码来源:calendar-month-view.component.spec.ts


示例10: it

      it('should flush tasks', fakeAsync(() => {
           let ran = false;
           setTimeout(() => { ran = true; }, 10);

           flush();
           expect(ran).toEqual(true);
         }));
开发者ID:AnthonyPAlicea,项目名称:angular,代码行数:7,代码来源:fake_async_spec.ts



注:本文中的@angular/core/testing.flush函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript testing.flushMicrotasks函数代码示例发布时间:2022-05-28
下一篇:
TypeScript testing.fakeAsync函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap