Skip to content

Instantly share code, notes, and snippets.

@matheusml
Created February 11, 2021 19:10
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 matheusml/5e604b3cc8fce1cb2512ae995fc03cfa to your computer and use it in GitHub Desktop.
Save matheusml/5e604b3cc8fce1cb2512ae995fc03cfa to your computer and use it in GitHub Desktop.
test('can open accordion items to see the contents', () => {
const hats = {title: 'Favorite Hats', contents: 'Fedoras are classy'}
const footware = {
title: 'Favorite Footware',
contents: 'Flipflops are the best',
}
render(<Accordion items={[hats, footware]} />)
expect(screen.getByText(hats.contents)).toBeInTheDocument()
expect(screen.queryByText(footware.contents)).not.toBeInTheDocument()
userEvent.click(screen.getByText(footware.title))
expect(screen.getByText(footware.contents)).toBeInTheDocument()
expect(screen.queryByText(hats.contents)).not.toBeInTheDocument()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment