当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript testing.tick函数代码示例

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


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

示例1: it

        it('should only keep a max of 3 alerts', fakeAsync(inject([AlertService], (service: AlertService) => {
            component.ngOnInit();

            service.successStatus$.next({title: 'myTitle1', text: 'myText', icon: '#icon', keep: true});

            tick();

            component['messages'].length.should.equal(1);

            component['messages'][0].should.deep.equal({title: 'myTitle1', text: 'myText', icon: '#icon', keep: true});

            service.successStatus$.next({title: 'myTitle2', text: 'myText', icon: '#icon', keep: true});

            tick();

            component['messages'].length.should.equal(2);

            component['messages'][0].should.deep.equal({title: 'myTitle1', text: 'myText', icon: '#icon', keep: true});
            component['messages'][1].should.deep.equal({title: 'myTitle2', text: 'myText', icon: '#icon', keep: true});

            service.successStatus$.next({title: 'myTitle3', text: 'myText', icon: '#icon', keep: true});

            tick();

            component['messages'].length.should.equal(3);

            component['messages'][0].should.deep.equal({title: 'myTitle1', text: 'myText', icon: '#icon', keep: true});
            component['messages'][1].should.deep.equal({title: 'myTitle2', text: 'myText', icon: '#icon', keep: true});
            component['messages'][2].should.deep.equal({title: 'myTitle3', text: 'myText', icon: '#icon', keep: true});

            service.successStatus$.next({title: 'myTitle4', text: 'myText', icon: '#icon', keep: true});

            tick();

            tick();

            component['messages'].length.should.equal(3);

            component['messages'][0].should.deep.equal({title: 'myTitle2', text: 'myText', icon: '#icon', keep: true});
            component['messages'][1].should.deep.equal({title: 'myTitle3', text: 'myText', icon: '#icon', keep: true});
            component['messages'][2].should.deep.equal({title: 'myTitle4', text: 'myText', icon: '#icon', keep: true});

            tick(messageTimeout);
        })));
开发者ID:GitWhiskey,项目名称:composer,代码行数:44,代码来源:success.component.spec.ts

示例2: it

        it('should load all the identities and handle those bound to participants not found', fakeAsync(() => {
            let myLoadParticipantsMock = sinon.stub(component, 'loadParticipants');
            let myGetParticipantMock = sinon.stub(component, 'getParticipant');

            myLoadParticipantsMock.returns(Promise.resolve());
            myGetParticipantMock.onFirstCall().returns(true);
            myGetParticipantMock.onSecondCall().returns(false);
            myGetParticipantMock.onThirdCall().returns(true);

            component.loadAllIdentities();

            tick();
            component['businessNetworkName'].should.equal('penguin-network');
            myLoadParticipantsMock.should.have.been.called;
            component['allIdentities'].length.should.deep.equal(4);
            component['allIdentities'][0]['ref'].should.deep.equal('bob@penguin-network');
            component['allIdentities'][0].should.not.have.property('state');
            component['allIdentities'][1]['ref'].should.deep.equal('cardOne');
            component['allIdentities'][1]['state'].should.deep.equal('BOUND PARTICIPANT NOT FOUND');
            component['allIdentities'][2]['ref'].should.deep.equal('networkAdmin');
            component['allIdentities'][2].should.not.have.property('state');
            component['allIdentities'][3]['name'].should.deep.equal('tony');
            component['allIdentities'][3].should.not.have.property('state');

            component['currentIdentity'].should.deep.equal(currentCardRef);
            component['identityCards'].size.should.deep.equal(3);
            component['identityCards'].get(currentCardRef).should.deep.equal(currentIdCard);
            component['identityCards'].get('cardOne').should.deep.equal(cardOne);
            component['myIDs'].length.should.deep.equal(3);
            component['myIDs'][0]['ref'].should.deep.equal('bob@penguin-network');
            component['myIDs'][0]['usable'].should.deep.equal(true);
            component['myIDs'][1]['ref'].should.deep.equal('cardOne');
            component['myIDs'][1]['usable'].should.deep.equal(false);
            component['myIDs'][2]['ref'].should.deep.equal('networkAdmin');
            component['myIDs'][2]['usable'].should.deep.equal(true);
        }));
开发者ID:marlonprudente,项目名称:composer,代码行数:36,代码来源:identity.component.spec.ts

示例3: it

  it('should receive and parse station information', fakeAsync(() => {
       const stations: StationMap = dashboardService.stations;
       dashboardService.subscribe();

       connectSuccessfully();
       const message = {};
       addStationToMessage(message, '12000', 'ONLINE');
       addStationToMessage(message, '12001', 'UNREACHABLE');
       receiveMockMessage(message);
       tick();

       expect(dashboardService.isSubscribing).toBe(false);
       expect(dashboardService.hasError).toBe(false);

       // The API responses should be converted into Station objects.
       expect(Object.keys(stations).length).toEqual(2);
       expect(stations['localhost:12000'].stationId)
           .toEqual('mock-station-12000');
       expect(stations['localhost:12000'].status).toEqual(StationStatus.online);
       expect(stations['localhost:12001'].stationId)
           .toEqual('mock-station-12001');
       expect(stations['localhost:12001'].status)
           .toEqual(StationStatus.unreachable);
     }));
开发者ID:kdsudac,项目名称:openhtf,代码行数:24,代码来源:dashboard.service.spec.ts

示例4: inject

                inject([JhiApplicationsService], (service: JhiApplicationsService) => {

                    spyOn(service, 'findAll').and.returnValue(Observable.of({
                        status: null,
                        applications: [
                            {
                                name: 'app1',
                                instances: [
                                    {
                                        instanceId: 1,
                                        status: 'UP'
                                    },
                                    {
                                        instanceId: 2,
                                        status: 'DOWN'
                                    }
                                ]
                            },
                            {
                                name: 'app2',
                                instances: [
                                    {
                                        instanceId: 3,
                                        status: 'UP'
                                    }
                                ]
                            }
                        ]
                    }));

                    comp.ngOnInit();
                    tick();

                    expect(service.findAll).toHaveBeenCalled();
                    expect(comp.appInstances.length).toEqual(3);
                })
开发者ID:BadgerPc,项目名称:jhipster-microservices-example,代码行数:36,代码来源:home.component.spec.ts

示例5: it

        it('should handle error adding identity to wallet', fakeAsync(() => {
            mockGetConnectionProfile.returns({
                type: 'web'
            });

            mockModal.open.returns({
                result: Promise.resolve({userID: 'myId', userSecret: 'mySecret'})
            });

            mockAddIdentityToWallet.rejects(new Error('add identity to wallet error'));

            mockAlertService.errorStatus$.next.should.not.have.been.called;

            component.issueNewId();

            tick();

            mockModal.open.should.have.been.calledOnce;

            let expectedError = sinon.match(sinon.match.instanceOf(Error).and(sinon.match.has('message', 'add identity to wallet error')));
            mockAlertService.errorStatus$.next.should.have.been.calledWith(expectedError);

            mockLoadAllIdentities.should.have.been.called;
        }));
开发者ID:bloonbullet,项目名称:composer,代码行数:24,代码来源:identity.component.spec.ts

示例6: it

  it('queryId should be emptied if the cancellation success', fakeAsync(() => {
    pcapService.cancelQuery = jasmine.createSpy('cancelQuery').and.returnValue(
      defer(() => Promise.resolve())
    );

    component.queryRunning = true;
    component.queryId = 'testid';
    fixture.detectChanges();

    const cancelBtn = fixture.debugElement.query(By.css('[data-qe-id="pcap-cancel-query-button"]'));
    const cancelBtnEl = cancelBtn.nativeElement;

    cancelBtnEl.click();
    fixture.detectChanges();

    const confirmButton = fixture.debugElement.query(By.css('.pcap-cancel-query-confirm-popover .btn-danger'));
    const confirmButtonEl = confirmButton.nativeElement;

    confirmButtonEl.click();
    tick();
    fixture.detectChanges();

    expect(component.queryId).toBeFalsy();
  }));
开发者ID:merrimanr,项目名称:incubator-metron,代码行数:24,代码来源:pcap-panel.component.spec.ts

示例7: it

    it('should notify on 409 conflict error (might be in trash)', fakeAsync(() => {
        findSitesSpy.and.returnValue(Promise.resolve(findSitesResponse));
        const error = { message: '{ "error": { "statusCode": 409 } }' };
        spyOn(alfrescoApi.sitesApi, 'createSite').and.callFake(() => {
            return new Promise((resolve, reject) => reject(error));
        });
        spyOn(alfrescoApi.sitesApi, 'getSite').and.callFake(() => {
            return new Promise((resolve, reject) => reject());
        });

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

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

        expect(component.form.controls.id.errors).toEqual({
            message: 'LIBRARY.ERRORS.CONFLICT'
        });
    }));
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:24,代码来源:library.dialog.spec.ts

示例8: inject

 inject([AuthService, MockBackend], fakeAsync((authService:AuthService, mockBackend:MockBackend) => {
   var result:IJsendResponse;
   mockBackend.connections.subscribe((c: MockConnection) => {
     expect(c.request.url).toBe('http://localhost:3000/api/auth/local');
     expect(c.request.headers.get('Content-Type')).toBe('application/json')
     expect(c.request.getBody()).toBe(JSON.stringify({ email: 'test@test.com', password: '12345' }));
     let mockResponseBody: IJsendResponse = {
       status: 'success',
       data: {
         'token': '12345'
       },
       message: ''
     };
     let response = new ResponseOptions({body: JSON.stringify(mockResponseBody)});
     c.mockRespond(new Response(response));
   });
   authService.login('test@test.com', '12345').subscribe(response => {
     result = response;
   });
   tick();
   expect(result.data.token).toBe('12345');
   expect(result.status).toBe('success');
   expect(localStorage.getItem('auth_token')).toBe('12345')
 }))
开发者ID:steelheaddigital,项目名称:angular2-express-starter,代码行数:24,代码来源:auth.service.spec.ts

示例9: it

    it('should insert a watch', fakeAsync(() => {

        let watch = JSON.parse(jsonUser).watches[0];
        watch.id = null;
        let result: Watch;

        twAPIService.upsertWatch(watch).then(
            response => { result = response; },
        );

        lastConnection.mockRespond(new Response(new ResponseOptions({
            body: JSON.stringify(watch),
        })));
        tick();

        expect(result.id).toEqual(watch.id);
        expect(result.brand).toEqual(watch.brand);
        expect(result.name).toEqual(watch.name);
        expect(result.yearOfBuy).toEqual(watch.yearOfBuy);
        expect(result.serial).toEqual(watch.serial);
        expect(result.caliber).toEqual(watch.caliber);

        expect(lastConnection.request.url).toEqual(twAPIService.config.getAPIUrl() + "watches", "should be consumed");
    }));
开发者ID:Toolwatchapp,项目名称:tw-common,代码行数:24,代码来源:twapi.service.spec.ts

示例10: it

        it('should handle error', fakeAsync(inject([SampleBusinessNetworkService], (service: SampleBusinessNetworkService) => {
            let repoMock = {
                contents: sinon.stub()
            };

            repoMock.contents.returns({
                fetch: sinon.stub().returns(Promise.reject('some error'))
            });

            let octoMock = {
                repos: sinon.stub().returns(repoMock)
            };

            service['octo'] = octoMock;
            service.getReadme('myOwner', 'myRepository', 'packages/')
                .then(() => {
                    throw('should not get here');
                })
                .catch((error) => {
                    error.should.equal('some error');
                });

            tick();
        })));
开发者ID:KlausSchwartz,项目名称:composer,代码行数:24,代码来源:samplebusinessnetwork.service.spec.ts


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