Skip to content

Commit

Permalink
add user event v14 test
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jun 19, 2023
1 parent 4392b44 commit bb2d6ef
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions code/addons/interactions/template/stories/basics.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,24 @@ export const Validation = {
await expect(args.onSuccess).not.toHaveBeenCalled();
},
};

export const UserEventSetup = {
play: async (context) => {
const { args, canvasElement, step } = context;
const user = userEvent.setup();
const canvas = within(canvasElement);
await step('Select, type and paste on input using user-event v14 setup', async () => {
const input = await canvas.getByRole('textbox');
await user.click(input);
await user.type(input, 'Pasting: ');
await user.paste('foobar');
});
await step('Tab and press enter on submit button', async () => {
await user.tab();
await user.keyboard('{enter}');
const submitButton = await canvas.findByRole('button');
await expect(submitButton).toHaveFocus();
await expect(args.onSuccess).toHaveBeenCalled();
});
},
};

0 comments on commit bb2d6ef

Please sign in to comment.