change to test Button click

This commit is contained in:
Matthew Taylor 2017-10-19 17:07:09 -04:00
parent d298282070
commit 41331e7afc
2 changed files with 17 additions and 24 deletions

View file

@ -0,0 +1,17 @@
/* eslint-env jest */
import React from 'react'; // eslint-disable-line no-unused-vars
import {shallow} from 'enzyme';
import Button from '../../../src/components/button/button.jsx'; // eslint-disable-line no-unused-vars, max-len
describe('Button', () => {
test('triggers callback when clicked', () => {
const onClick = jest.fn();
const componentShallowWrapper = shallow(
<Button onClick={onClick}>
{'Button'}
</Button>
);
componentShallowWrapper.simulate('click');
expect(onClick).toHaveBeenCalled();
});
});

View file

@ -1,24 +0,0 @@
/* eslint-env jest */
import React from 'react'; // eslint-disable-line no-unused-vars
import {shallow} from 'enzyme';
import ToolSelectComponent from '../../../src/components/tool-select-base/tool-select-base.jsx'; // eslint-disable-line no-unused-vars, max-len
describe('ToolSelectComponent', () => {
test('triggers callback when clicked', () => {
const onClick = jest.fn();
const componentShallowWrapper = shallow(
<ToolSelectComponent
imgDescriptor={{
defaultMessage: 'Select',
description: 'Label for the select tool, which allows selecting, moving, and resizing shapes',
id: 'paint.selectMode.select'
}}
imgSrc={''}
isSelected={false}
onMouseDown={onClick}
/>
);
componentShallowWrapper.simulate('click');
expect(onClick).toHaveBeenCalled();
});
});