Skip to content

Instantly share code, notes, and snippets.

@justusromijn
Created June 11, 2019 19:26
Show Gist options
  • Save justusromijn/8eaa3bb14350acdf1b0ae695b052ffa2 to your computer and use it in GitHub Desktop.
Save justusromijn/8eaa3bb14350acdf1b0ae695b052ffa2 to your computer and use it in GitHub Desktop.
Smart React Component test
import { shallow } from 'enzyme';
import * as React from 'react';
import { ButtonBash } from './buttonBash';
import { Button } from './button';
describe('<ButtonBash />', () => {
it('renders a button and a bash count', () => {
let component = shallow(<ButtonBash />);
expect(component.contains(<p>Bashes: 0</p>).toBeTruthy();
});
it('updates the count after bashing', () => {
let component = shallow(<ButtonBash />);
component.find(Button).props().onClick();
expect(component.contains(<p>Bashes: 1</p>).toBeTruthy();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment