I want an Angular test that mocks keydown of keys 1 and 2 and then assert that the value of the input is 12
My html:
<input
id="myInput"
/>
My test:
fit('should update input value on key press', () => {
const inputDebugElement = fixture.debugElement.query(
By.css('#money-input')
);
const inputElement = inputDebugElement.nativeElement as HTMLInputElement;
inputElement.value = '';
inputElement.dispatchEvent(new Event('input'));
const event1 = new KeyboardEvent('keydown', { key: '1' });
const event2 = new KeyboardEvent('keydown', { key: '2' });
inputElement.dispatchEvent(event1);
inputElement.dispatchEvent(event2);
fixture.detectChanges();
expect(inputElement.value).toBe('12');
});