I am new to the Angular unit test.
We have used the jest testing framework in Angular.
I have basic knowledge in jest and can work with the basic testing. But in Angular routing I feel is complex
import { Component } from '@angular/core';
import { Router, RouteConfigLoadStart, RouteConfigLoadEnd, RouterEvent, NavigationStart, NavigationEnd, Event, NavigationCancel,
NavigationError } from '@angular/router';
import { NgxSpinnerService } from 'ngx-spinner';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'Angular';
loading: boolean = false;
constructor(router: Router, private spinner: NgxSpinnerService) {
router.events.subscribe(
(event: RouterEvent): void => {
if (event instanceof RouteConfigLoadStart) {
this.loading = true;
} else if (event instanceof RouteConfigLoadEnd) {
this.loading = false;
}
}
);
}
}
Can anyone help me with how to test the above code?