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