** Ниже мой код component.ts. Я хочу провести модульное тестирование метода диспетчерского действия моего компонента (выделено жирным шрифтом ниже) с помощью Jest. Может ли кто-нибудь предоставить мне решение или какие-либо ссылки / документы для модульного тестирования этого действия отправки?
import { Component, OnInit ,OnDestroy} from '@angular/core';
import { Store, select } from '@ngrx/store';
import * as fromBook from '../books.reducer';
import * as BookActions from '../books.actions';
import { Book, BookItems } from '../book';
import { Subscription, from, Observable } from 'rxjs';
import { Router, ActivatedRoute, ParamMap} from '@angular/router';
@Component({
selector: 'tmobile-search',
templateUrl: './search.component.html',
styleUrls: ['./search.component.scss']
})
export class SearchComponent implements OnInit, OnDestroy {
searchValue = '';
books$: Observable<BookItems[]>;
constructor(private store: Store<fromBook.State>,
private route: Router) { }
ngOnInit(): void {
this.books$ = this.store.pipe(select(fromBook.getBooks)) as Observable<BookItems[]>;
}
ngOnDestroy(): void {
}
***// I want to unit test this method using jest.***
**searchBtnClicked(){
this.store.dispatch(new BookActions.Load(this.searchValue));
}**
bookSelected(id){
console.log(id);
this.route.navigate(['search/bookDetail',id]);
}
}
I have gone through many articles but could not find the right one. Anyone helps would be much thankful.