I have an observable called isSearchEnabled$, that indicates whether the search button on search form is clickable or not. This is the code for the observable:
isSearchEnabled$ = anotherObject.errorSource$.pipe(map((errors) => errors.length === 0);
As one can see, this observable is depending on another observable, which emits an array every time form validation occurs. So isSearchEnabled emits a boolean true when the array is empty, false otherwise.
I wanna test this observable, but I'm not sure how. I should mock anotherObject.errorSource$
to emit fake errors, and check whether isSearchEnabled$
returns true or false?
How should i do it in Angular/RxJS? If somebody have solution in spectator, or just a regular solution, I'd really appreciate it!
PS.: I know I should provide a working example, but I think this description is quiet straightforward, and no need further code.
Aucun commentaire:
Enregistrer un commentaire