mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 13:32:28 -05:00
change to test Button
click
This commit is contained in:
parent
d298282070
commit
41331e7afc
2 changed files with 17 additions and 24 deletions
17
test/unit/components/button-click.test.jsx
Normal file
17
test/unit/components/button-click.test.jsx
Normal 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();
|
||||
});
|
||||
});
|
|
@ -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();
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue