I'm writing unit test cases in Angular 7 in this process got stuck to create unit test for a service variable 'isLoading'.
here is my app component html file:
<router-outlet></router-outlet>
<div *ngIf="guestUserService.isLoading | async" class="loaderdiv">
<mat-spinner class="loader"></mat-spinner>
</div>
Run Code Online (Sandbox Code Playgroud)
The service file:
export class GuestUserService {
public isLoading: any = new BehaviorSubject(false);
}
Run Code Online (Sandbox Code Playgroud)
The unit test case:
fdescribe('AppComponent', () => {
let guestUserService: any;
let guestUserServiceSpy: any;
beforeEach(async(() => {
guestUserService = jasmine.createSpyObj('GuestUserService', ['isLoading']);
TestBed.configureTestingModule({
providers: [
{ provide: GuestUserService, useValue: …Run Code Online (Sandbox Code Playgroud)