Skip to content

Instantly share code, notes, and snippets.

@mtheoryx
Created January 2, 2017 20:51
Show Gist options
  • Save mtheoryx/72349fa38992a30d63d7d5a6df693c23 to your computer and use it in GitHub Desktop.
Save mtheoryx/72349fa38992a30d63d7d5a6df693c23 to your computer and use it in GitHub Desktop.
DeleteButton.test.js
//noinspection JSUnresolvedVariable
import React from 'react';
//noinspection JSUnresolvedVariable
import ReactDOM from 'react-dom';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import DeleteButton from './DeleteButton';
describe('DeleteButton component', () => {
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<DeleteButton itemId={'student1'} onDelete={() => {}}/>, div);
});
it('handles a click event', () => {
const onButtonClick = sinon.spy();
const Btn = shallow(
<DeleteButton onDelete={onButtonClick} itemId={'student1'}/>
);
Btn.find('button').simulate('click');
expect(onButtonClick.calledOnce).toEqual(true);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment