Skip to content

Commit

Permalink
Add test for input component
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileyJames committed Jul 17, 2021
1 parent 77f1b0d commit 391120b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/src/components/input/Input.test.js
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);
})
})

0 comments on commit 391120b

Please sign in to comment.