forked from yamada-ui/yamada-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request yamada-ui#682 from Sahillather002/tests/color-picker
tests for color-picker
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
packages/components/color-picker/tests/colorPicker.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
}) | ||
}) |