Last active
September 23, 2020 21:27
-
-
Save lai32290/b882dc35dc219b23e1feded30782bed1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// __tests__/accordion.enzyme.js | |
import React from 'react' | |
// if you're wondering why not shallow, | |
// then please read <https://kcd.im/shallow> | |
import Enzyme, {mount} from 'enzyme' | |
import EnzymeAdapter from 'enzyme-adapter-react-16' | |
import Accordion from '../accordion' | |
// Setup enzyme's react adapter | |
Enzyme.configure({adapter: new EnzymeAdapter()}) | |
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