Skip to content

Instantly share code, notes, and snippets.

@fakiolinho
Last active March 13, 2018 10:28
Show Gist options
  • Save fakiolinho/4132c6216eca6d75849a7634f20fd3cc to your computer and use it in GitHub Desktop.
Save fakiolinho/4132c6216eca6d75849a7634f20fd3cc to your computer and use it in GitHub Desktop.
import React from 'react';
import { shallow } from 'enzyme';
import Card from './';
describe('test Card component', () => {
it('should render the component', () => {
const enzymeWrapper = shallow(<Card />);
expect(enzymeWrapper).toHaveLength(1);
});
it('state should change when salute button gets clicked', () => {
const enzymeWrapper = shallow(<Card />);
expect(enzymeWrapper.state('salute')).toBeFalsy();
enzymeWrapper.find('button').at(0).simulate('click');
expect(enzymeWrapper.state('salute')).toBeTruthy();
expect(enzymeWrapper.find('button').at(0).text()).toEqual(
'You said hi',
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment