I am trying to test the ngOnDestroy() method of this component but not able to find the correct way to do that. What should be the right way to do it?
import {Component, OnDestroy} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {Subject} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
@Component({.......})
export class MyComponent implements OnDestroy {
private readonly destroyed = new Subject();
constructor(private readonly route: ActivatedRoute) {
this.route.queryParams.pipe(takeUntil(this.destroyed)).subscribe(params => {
// custom code here
});
}
ngOnDestroy() {
this.destroyed.next();
this.destroyed.complete();
}
}