如何通过以下代码检查this.someService.someProperties
是否已订阅:
SomeMethod(){
this.someService.someProperties.subscribe((data) => {
//...
});
}
it('Should call subscribe() ', () => {
someService.push({});
let currentPropertiesSpy = spyOn(someService, 'someProperty') ;
component.someMethod();
expect(currentPropertiesSpy).toHaveBeenCalled();
});
class someServiceStub {
private propertiesSource = new BehaviorSubject(this.defaultProperties);
currentProperties = this.propertiesSource.asObservable();
push(val){
this.propertiesSource.next(val);
}
}