Skip to content

Instantly share code, notes, and snippets.

@matheusml
Created February 11, 2021 19:09
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/9a4c64bcdb20c3b1cfcf51aeda5c9f77 to your computer and use it in GitHub Desktop.
Save matheusml/9a4c64bcdb20c3b1cfcf51aeda5c9f77 to your computer and use it in GitHub Desktop.
test('setOpenIndex sets the open index state properly', () => {
const wrapper = mount(<Accordion items={[]} />)
expect(wrapper.state('openIndex')).toBe(0)
wrapper.instance().setOpenIndex(1)
expect(wrapper.state('openIndex')).toBe(1)
})
test('Accordion renders AccordionContents with the item contents', () => {
const hats = {title: 'Favorite Hats', contents: 'Fedoras are classy'}
const footware = {
title: 'Favorite Footware',
contents: 'Flipflops are the best',
}
const wrapper = mount(<Accordion items={[hats, footware]} />)
expect(wrapper.find('AccordionContents').props().children).toBe(hats.contents)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment