-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure input component can be assigned type
- Loading branch information
Showing
2 changed files
with
13 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -5,13 +5,23 @@ import { Input } from "./Input"; | |
describe("<Input />", () => { | ||
test("renders text input", () => { | ||
const value = "[email protected]"; | ||
const { getByTestId, queryByTestId } = render(<Input defaultValue={value} />); | ||
const { getByTestId, queryByTestId } = render(<Input type="text" defaultValue={value} />); | ||
|
||
expect(getByTestId("input")).toHaveAttribute("type", "text"); | ||
expect(getByTestId("input")).toHaveValue(value); | ||
expect(queryByTestId("toggle-password-visibility-button")).toBeFalsy(); | ||
}); | ||
|
||
test("renders other type of input", () => { | ||
const type = "number"; | ||
const value = 888; | ||
const { getByTestId, queryByTestId } = render(<Input type={type} defaultValue={value} />); | ||
|
||
expect(getByTestId("input")).toHaveAttribute("type", type); | ||
expect(getByTestId("input")).toHaveValue(value); | ||
expect(queryByTestId("toggle-password-visibility-button")).toBeFalsy(); | ||
}); | ||
|
||
test("renders password input with visibilty button", () => { | ||
const value = "eight888"; | ||
const { getByTestId, getByRole } = render(<Input type="password" defaultValue={value} />); | ||
|
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