Skip to content

Commit

Permalink
feat: improved tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackshelton-kunaico committed Nov 24, 2024
1 parent 3b604e6 commit 0dc00e4
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions libs/components/src/checkbox/checkbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,28 @@ test.describe("forms", () => {
await page.getByRole("button").last().click();
await expect(page.getByText("Submitted")).not.toBeVisible();
});

test(`GIVEN a checkbox inside a form
WHEN submitting the form
THEN an error message should be displayed
`, async ({ page }) => {
const d = await setup(page, "validation");

await page.getByRole("button").last().click();
await expect(d.getErrorMessage()).toBeVisible();
await expect(d.getTrigger()).toHaveAttribute("aria-invalid", "true");
await expect(d.getTrigger()).toHaveAttribute("aria-describedby");
});

test(`GIVEN a checkbox inside a form
WHEN a different value is provided to the checkbox
THEN the form should submit that value instead of "on"
`, async ({ page }) => {
const d = await setup(page, "value");

await d.getTrigger().click();
await expect(d.getHiddenInput()).toBeChecked();
await page.getByRole("button").last().click();
await expect(page.getByText(`Submitted: { "terms": "checked" }`)).toBeVisible();
});
});

0 comments on commit 0dc00e4

Please sign in to comment.