Skip to content

Commit

Permalink
test(controller/autocomplete): adding test assertion to ensure handle…
Browse files Browse the repository at this point in the history
…rs are not even run
  • Loading branch information
korgon committed Dec 9, 2024
1 parent bc859c6 commit 3361def
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ describe('Autocomplete Controller', () => {

const form = inputEl!.form;
const beforeSubmitfn = jest.spyOn(controller.eventManager, 'fire');
const handlerSubmitfn = jest.spyOn(controller.handlers.input, 'formSubmit');

form?.dispatchEvent(new Event('submit', { bubbles: true }));
//this timeout seems to be needed. Cant replace with waitFor
Expand All @@ -737,6 +738,8 @@ describe('Autocomplete Controller', () => {
input: inputEl!,
});

expect(handlerSubmitfn).not.toHaveBeenCalled();

beforeSubmitfn.mockClear();
});

Expand All @@ -757,6 +760,7 @@ describe('Autocomplete Controller', () => {
(controller.client as MockClient).mockData.updateConfig({ autocomplete: 'autocomplete.query.bumpers' });

const beforeSubmitfn = jest.spyOn(controller.eventManager, 'fire');
const enterKeyfn = jest.spyOn(controller.handlers.input, 'enterKey');
const inputEl: HTMLInputElement | null = document.querySelector(controller.config.selector);

const query = 'bumpers';
Expand All @@ -772,6 +776,8 @@ describe('Autocomplete Controller', () => {
input: inputEl!,
});

expect(enterKeyfn).not.toHaveBeenCalled();

beforeSubmitfn.mockClear();
});

Expand Down

0 comments on commit 3361def

Please sign in to comment.