Skip to content

Instantly share code, notes, and snippets.

@Dromediansk
Created June 11, 2020 04:23
Show Gist options
  • Save Dromediansk/4148312f22b31d054aac81d54e946116 to your computer and use it in GitHub Desktop.
Save Dromediansk/4148312f22b31d054aac81d54e946116 to your computer and use it in GitHub Desktop.
Filtering countries test
it("should filter countries by name when input value is changed", () => {
useFetch.mockReturnValue({
loading: false,
data: stubbedCountries,
error: null,
});
const { getByTestId } = render(<CountriesContainer />);
act(() => {
fireEvent.change(getByTestId("filter-input-name"), {
target: { value: "Slov" },
});
});
expect(getByTestId("countries-container").children).toHaveLength(1);
expect(getByTestId("countries-container").textContent).toContain(
"Slovakia"
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment