Skip to content

Commit

Permalink
Merge pull request yamada-ui#682 from Sahillather002/tests/color-picker
Browse files Browse the repository at this point in the history
tests for color-picker
  • Loading branch information
hirotomoyamada authored Feb 7, 2024
2 parents c512da6 + e1f6818 commit 78f8cb5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/components/color-picker/tests/colorPicker.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { render, screen, fireEvent } from "@yamada-ui/test"
import { ColorPicker } from "../src"

describe("<ColorPicker />", () => {
test("ColorPicker renders correctly", async () => {
render(<ColorPicker data-testid="colorPicker" />)

const colorPicker = screen.getByTestId("colorPicker")

expect(colorPicker).toBeInTheDocument()
})

test("ColorPicker changes color on selecting a new color", () => {
render(<ColorPicker data-testid="colorPicker" />)

const colorPicker = screen.getByTestId("colorPicker")
const value = "#ff0000"

fireEvent.change(colorPicker, { target: { value } })

expect(colorPicker).toHaveValue(value)
})

test("ColorPicker renders with the correct initial value", () => {
render(<ColorPicker defaultValue="#00ff00" data-testid="colorPicker" />)

const colorPicker = screen.getByTestId("colorPicker")

expect(colorPicker).toHaveValue("#00ff00")
})
})

0 comments on commit 78f8cb5

Please sign in to comment.