Просто следуйте документам:
function asyncData<T>(data: T) {
return defer(() => Promise.resolve(data));
}
describe('Example test', () => {
let component: MyComponent;
let fixture: ComponentFixture<MyComponent>;
let getConditionTypesSpy: any;
beforeEach(() => {
const fakeListDataService = jasmine.createSpyObj('ListDataService', ['getConditionTypes']);
getConditionTypesSpy = fakeListDataService.getConditionTypes.and.returnValue('>');
TestBed.configureTestingModule({
declarations: [ MyComponent ],
providers: [
{ provide: ListDataService, useValue: fakeListDataService }
]
});
fixture = TestBed.createComponent(MyComponent);
component = fixture.componentInstance;
fixture.detectChanges()
});
it('should test greater then in switch', fakeAsync(() => {
// call getConditionTypes (it'll call the observable)
component.getConditionTypes();
fixture.detectChanges();
tick();
// check whatever you want
}));
});