lundi 24 septembre 2018

check variable after service call in angular testing script

ahanaService is service, tenantList is component variable and getTenantLists is service method

it('should have as all tenant list', fakeAsync(() => {
    const fixture = TestBed.createComponent(AppComponent);
    const comp = fixture.debugElement.componentInstance;
    spyOn(comp['ahanaService'], 'getTenantLists').and.callThrough();
    comp.ngOnInit();
    tick();
    expect(comp['tenantList']).not.toBe(null);
  }));

Aucun commentaire:

Enregistrer un commentaire