Commit bcc4a85d authored by Mickaël Bourgier's avatar Mickaël Bourgier
Browse files

Remove ButtonGroup snapshot testing

parent 90e80f00
Pipeline #974 passed with stage
in 1 minute and 42 seconds
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer'; import { render } from '@testing-library/react';
import { SheetsRegistry } from 'react-jss';
import { createTheme } from '../styles';
import wrapToTest from '../utils/wrapToTest'; import wrapToTest from '../utils/wrapToTest';
import Button from '../Button';
import ButtonGroup from './ButtonGroup'; import ButtonGroup from './ButtonGroup';
import Button from './../Button'; import IconButton from '../IconButton';
describe('<ButtonGroup />', () => { describe('<ButtonGroup />', () => {
let componentToTest; describe('color prop', () => {
let sheets; it('must set the background color of buttons if they do not override', () => {
let theme; const palette = {
success: 'green',
beforeEach(() => { danger: 'red'
componentToTest = null;
sheets = null;
theme = null;
});
afterEach(() => {
if (componentToTest !== null) {
const options = {
...(sheets !== null ? { sheets } : {}),
...(theme !== null ? { theme } : {})
}; };
const component = renderer.create(wrapToTest(options)(componentToTest)); const { getAllByText } = render(
wrapToTest({
expect(component.toJSON()).toMatchSnapshot(); theme: createTheme({ colors: { palette } })
if (sheets !== null) { })(
expect(sheets.toString()).toMatchSnapshot(); <ButtonGroup color='success'>
} <Button>success</Button>
} <Button>success</Button>
}); <Button color='danger'>danger</Button>
<Button>success</Button>
test('Render with children', () => { </ButtonGroup>
componentToTest = ( )
<ButtonGroup> );
<Button>Hello</Button>
<Button> getAllByText(/success/).forEach(element => {
<strong>you</strong> expect(element).toHaveStyle(`background-color: ${palette.success};`);
</Button> });
</ButtonGroup> getAllByText(/danger/).forEach(element => {
); expect(element).toHaveStyle(`background-color: ${palette.danger};`);
sheets = new SheetsRegistry(); });
});
}); });
test('Should include className and other props', () => { describe('pill prop', () => {
componentToTest = ( it('must round buttons and icon buttons', () => {
<ButtonGroup className={'my-custom-classname'} customProp={'fez'}> const Icon = () => 'icon';
<Button>Hello</Button>
<Button> const { getByText } = render(
<strong>you</strong> wrapToTest()(
</Button> <ButtonGroup pill>
</ButtonGroup> <Button>button</Button>
); <IconButton>
<Icon />
</IconButton>
</ButtonGroup>
)
);
expect(getByText(/button/)).toHaveStyle(`border-radius: 100rem`);
expect(getByText(/icon/)).toHaveStyle(`border-radius: 100rem`);
});
}); });
}); });
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment