Spaces:
Running
Running
File size: 1,153 Bytes
6bcb42f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import React from 'react';
import {shallow} from 'enzyme';
import IconButton from '../../../src/components/icon-button/icon-button';
import renderer from 'react-test-renderer';
describe('IconButtonComponent', () => {
test('matches snapshot', () => {
const onClick = jest.fn();
const title = <div>Text</div>;
const imgSrc = 'imgSrc';
const className = 'custom-class-name';
const component = renderer.create(
<IconButton
className={className}
img={imgSrc}
title={title}
onClick={onClick}
/>
);
expect(component.toJSON()).toMatchSnapshot();
});
test('triggers callback when clicked', () => {
const onClick = jest.fn();
const title = <div>Text</div>;
const imgSrc = 'imgSrc';
const componentShallowWrapper = shallow(
<IconButton
img={imgSrc}
title={title}
onClick={onClick}
/>
);
componentShallowWrapper.simulate('click');
expect(onClick).toHaveBeenCalled();
});
});
|