Skip to content

Commit

Permalink
test: add test to valid onBlur has been called
Browse files Browse the repository at this point in the history
  • Loading branch information
shuowu-okta committed Dec 1, 2023
1 parent 18ba778 commit 187e42e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,16 @@ export default storybookMeta;
const checkTheBox =
({ canvasElement, step }: PlaywrightProps<CheckboxProps>) =>
async (actionName: string) => {
await step("check the box", async () => {
await step("check the box", async ({ args }) => {
const canvas = within(canvasElement);
const checkBox = canvas.getByRole("checkbox") as HTMLInputElement;
if (checkBox) {
userEvent.click(checkBox);
}
userEvent.tab();
expect(checkBox).toBeChecked();
userEvent.click(canvasElement);
expect(args.onBlur).toHaveBeenCalled();
axeRun(actionName);
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ export default storybookMeta;

export const Default: StoryObj<typeof Radio> = {
play: async ({ canvasElement, step }) => {
await step("select the radio button", async () => {
await step("select the radio button", async ({ args }) => {
const canvas = within(canvasElement);
const radio = canvas.getByRole("radio") as HTMLInputElement;
if (radio) {
userEvent.click(radio);
}
expect(radio).toBeChecked();
userEvent.click(canvasElement);
expect(args.onBlur).toHaveBeenCalled();
axeRun("Radio Default");
});
},
Expand Down

0 comments on commit 187e42e

Please sign in to comment.