Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt committed Apr 15, 2024
1 parent 62b3174 commit 79405b1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions src/components/DatePicker/datepicker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ test.describe("Expect date picker single", () => {
.getByLabel("Select A year from now"),
).toBeVisible()
})
test("with time to be rendered", async ({ page }) => {
await page.goto(
"http://localhost:6006/?path=/story/ui-datepicker--controlled-time",
)
await page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByRole("button", { name: "Select date" })
.click()
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByLabel("hour, Time"),
).toBeVisible()
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByLabel("minute, Time"),
).toBeVisible()
})
})

test.describe("Expect date picker range", () => {
Expand Down Expand Up @@ -248,4 +267,33 @@ test.describe("Expect date picker range", () => {
.getByLabel("Year to date"),
).toBeVisible()
})
test("with time to be rendered", async ({ page }) => {
await page.goto(
"http://localhost:6006/?path=/story/ui-daterangepicker--controlled-time-range",
)
await page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByRole("button", { name: "Select date" })
.click()
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByLabel("hour, Start date time"),
).toBeVisible()
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByLabel("minute, Start date time"),
).toBeVisible()
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByLabel("hour, End date time"),
).toBeVisible()
await expect(
page
.frameLocator('iframe[title="storybook-preview-iframe"]')
.getByLabel("minute, End date time"),
).toBeVisible()
})
})
2 changes: 1 addition & 1 deletion src/components/DatePicker/datepicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const ControlledTimeDemo = () => {
</p>
<div className="flex w-96 gap-2">
<DatePicker
className="w-60"
className="w-60"
showTimePicker
value={value}
onChange={(value) => {
Expand Down

0 comments on commit 79405b1

Please sign in to comment.