Skip to content

Instantly share code, notes, and snippets.

@arshmakker
Created May 14, 2020 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arshmakker/cca3bed774aa1a9ce7729f99fff6a6c1 to your computer and use it in GitHub Desktop.
Save arshmakker/cca3bed774aa1a9ce7729f99fff6a6c1 to your computer and use it in GitHub Desktop.
Functional test case fo Header Component
//functional testing
it('Renders the correct results after the search keyword is entered', () => {
render(<Header InitialData={SampleData}/>)
fireEvent.change(screen.getByTestId("searchText"),
{ target: { value: "2nd" } })
expect(screen.getByTestId("searchText").value).toBe("2nd")
fireEvent.click(screen.getByRole('button'))
expect(screen.getAllByText(/2nd/i).length).toBe(2)
expect(screen.getAllByText(/1st/i).length).toBe(1)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment