features) Let your acceptance test fail while we implement our components and reducers Component Tests (Tests your components) Mock out the API you want redux to inject Mock out the API you want dependent components to expose Redux Tests Use your tests to design your the API of your action creators and selectors
assert the rendered state Test both sides of conditions inside render() Use simulate(event) to test that the correct behavior occurs in response to specific events
shallow(<AudioPlayer />) expect(wrapper.html()).toBe(null) }) it('should render if there is an episode',()=> { let wrapper = shallow(<AudioPlayer episode={episode} />) let title = wrapper.find(‘.episode-title') expect(title.text()).toBe(episode.title) })
'enzyme'; it('renders MyComponent components', () => { // shallow just renders to the next Component boundary const wrapper = shallow(<MyComponent />); // mount renders the fill render tree const wrapper = mount(<MyComponent />); // static renders to a string const wrapper = static(<MyComponent />); });
'enzyme'; it('renders MyComponent components', () => { // shallow just renders to the next Component boundary const wrapper = shallow(<MyComponent />); // mount renders the fill render tree const wrapper = mount(<MyComponent />); // static renders to a string const wrapper = static(<MyComponent />); });
'enzyme'; it('renders MyComponent components', () => { // shallow just renders to the next Component boundary const wrapper = shallow(<MyComponent />); // mount renders the fill render tree const wrapper = mount(<MyComponent />); // static renders to a string const wrapper = static(<MyComponent />); });
'enzyme'; it('renders MyComponent components', () => { // shallow just renders to the next Component boundary const wrapper = shallow(<MyComponent />); // mount renders the fill render tree const wrapper = mount(<MyComponent />); // static renders to a string const wrapper = static(<MyComponent />); });
your app Make a createStore() helper for instantiating your store with all its reducers and middleware Test action creators, reducers, and selectors all at once
helpers boots up the `<App>`, routes // to `/`, and waits for any data to load // before returning an enzyme mount() object let page = await visit('/') expect(page.find(‘.episode').length).toBe(4); let episode = page.find(‘.episode').first(); expect(episode.find(‘.title').text()) .toBe('7.08- The Political Question’); });
{ let page = await visit('/'); page.find('.play').simulate('click'); let player = page.find('.audio-player'); expect(player).toHaveClassName('playing'); });