#angular #testing
Вопрос:
Я новичок в angular, и у меня есть некоторые вопросы с тестированием по методу ismobile. Ниже приведена часть кода на homecompoonent.ts:
ngOnInit(): void {
this.mapService.mapLoaded$.subscribe(
state => {
this.loadingState = state;
}
);
if (!this.isMobile || this.selectedView === 'map') {
this.mapService.canLoadMap$.next(true);
} else { this.mapService.triggerMapLoadedTransition(); }
this.filterService.canLoadFilter$.next(true);
}
I am trying to test the partialMapService to return to true when !ismobile but couldn't make it work. here's the code so far:
fit(`should push a true value in the partialMapService`, () => {
!(component.isMobile);
fixture.detectChanges();
partialMapService.canLoadMap$.subscribe((val) => {
expect(val).toEqual(true);
})
});
I'm not sure !(component.isMobile) is not the way to put it there but it's expecting null value which is not correct. what is the right way to test ismobile to return canLoadMap to true?