I'm having trouble figuring out how to simulate a change in the value of a dropdown list in my jasmine unit test.
When the dropdown list value is changed, it emits an event.
My current test looks like:
spyOn(component.varChange, 'emit');
let selectEl: DebugElement = fixture.debugElement.query(By.css("#selectBox"));
selectEl.nativeElement.selectedIndex = 0;
selectEl.nativeElement.dispatchEvent(new Event("input"));
fixture.detectChanges();
expect(component.varChange.emit).toHaveBeenCalledWith(testData[0]);
The error I receive is:Expected spy emit to have been called with [ Object({ ... }) ] but it was never called.
Aucun commentaire:
Enregistrer un commentaire