In my Angular5 app, I have a mat-select for a list of dates. When the user selects a new date from the options, my selectionChange processor kicks off a request for data.
I'm trying to write a Jasmine test to simulate the user interaction to verify that the processing is done correctly. I don't know how to get the mat-select to select a value and emit selectionChange as if the user made the selection.
I've seen an issue on the Angular Material2 GitHub (issue 5082) that references the tests for mat-select - I tried to create an down-arrow keydown event to trigger selection of the next item:
let selCtrl = fixture.nativeElement.querySelector('mat-select');
selCtrl.dispatchEvent(new KeyboardEvent({key: 'ArrowDown', code: 'ArrowDown'});
However, this doesn't appear to be working - checking the event I create and the mat-select code it appears that keyCode isn't being created, and it's required by mat-select.
I've tried setting the value of the control programmatically, but this doesn't trigger emitting of selectionChanged.
Any suggestions of how to trigger changes to mat-select from a Jasmine test?