-
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.
- Loading branch information
1 parent
77f1b0d
commit 391120b
Showing
1 changed file
with
21 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Input from "./index"; | ||
import { render } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
describe("Labelled Input", () => { | ||
test("Input has value and calls onChange", () => { | ||
const onChange = jest.fn(); | ||
const value = "Hello world" | ||
const label = "Form input" | ||
|
||
const { getByLabelText } = render( | ||
<Input label={label} onChange={onChange} value={value} /> | ||
); | ||
|
||
const input = getByLabelText("Form input"); | ||
expect(input.value).toBe("Hello world") | ||
|
||
userEvent.type(input, 'User input'); | ||
expect(onChange).toHaveBeenCalledTimes(10); | ||
}) | ||
}) |