I am trying to write a unit test for one of the dropdown with a search box at its top associated with it. The problem is that valueChanges is not getting fired and I am unable to see the filteredValues
to put an assert on. I see the searchbox being updated with value 'S2' but don't see valueChanges from component getting called. Any help on what am I doing wrong here is much appreciated.
Unit Test :
it('should search for stores', fakeAsync(() => {
initTest('add');
fixture.detectChanges();
fixture.nativeElement.querySelector('#select').click();
fixture.detectChanges();
const d = overlayContainer.getContainerElement().querySelector('#search');
d.textContent = 'S2';
d.dispatchEvent(new Event('input'));
flush();
fixture.detectChanges();
fixture.whenStable().then(() => {
component.filteredValues.subscribe(value => {
console.log('Value :: ' + JSON.stringify(value));
});
});
}));
Inside component :
this.search.valueChanges.pipe(takeUntil(this._destroyed)).subscribe(searchText => {
this.filteredValues = of(this.filterValue(searchText));
});