Skip to content

Commit

Permalink
Merge pull request #15502 from RogueTea/colour-picker-unit-text-fix
Browse files Browse the repository at this point in the history
Fixes #15501 : Broken colour picker unit test
  • Loading branch information
cetincakiroglu authored May 9, 2024
2 parents 2cd0548 + 2ec238e commit 2dd6a84
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/app/components/colorpicker/colorpicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,19 +136,15 @@ describe('ColorPicker', () => {
fixture.detectChanges();

const hideSpy = spyOn(colorpicker, 'hide').and.callThrough();
const keydownSpy = spyOn(colorpicker, 'onInputKeydown').and.callThrough();
const inputEl = fixture.debugElement.query(By.css('.p-inputtext'));
const openEvent: any = document.createEvent('CustomEvent');
openEvent.which = 32;
openEvent.initEvent('keydown', true, true);
inputEl.nativeElement.dispatchEvent(openEvent);
inputEl.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { code: 'Space', keyCode: 32 }));
fixture.detectChanges();

expect(keydownSpy).toHaveBeenCalled();
let selectorEl = fixture.debugElement.query(By.css('.p-colorpicker-panel'));
expect(selectorEl).toBeTruthy();
const escapeEvent: any = document.createEvent('CustomEvent');
escapeEvent.which = 27;
escapeEvent.initEvent('keydown', true, true);
inputEl.nativeElement.dispatchEvent(escapeEvent);
inputEl.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { code: 'Escape', keyCode: 27 }));
fixture.detectChanges();

selectorEl = fixture.debugElement.query(By.css('.p-colorpicker-panel'));
Expand Down

0 comments on commit 2dd6a84

Please sign in to comment.