import * as React from 'react';
import { renderHook } from '@testing-library/react-hooks';
import { SwitchGroup } from '../SwitchGroup';
import render from '../../utils/_tests/render';
describe('props', () => {
it('should render correctly', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly with CSS props', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly for default value', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly for default value (array)', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly for disabled fields', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly for disabled field', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly for horizontal fields', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
['success', 'danger', 'warning'].forEach((state) => {
it(`should render correctly for state ${state}`, () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
});
});
describe('composition', () => {
describe('as', () => {
it('should render correctly', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('hook', () => {
it('should return with SwitchGroup props', () => {
const { result } = renderHook(() =>
SwitchGroup.useProps({
name: 'weather',
options: [
{ label: 'Hello', value: 'world' },
{ label: 'This is', value: 'me' },
],
})
);
expect(result.current).toMatchSnapshot();
});
});
describe('render props', () => {
it('should render correctly', () => {
const { container } = render(
{(SwitchGroupProps) => Hello world
}
);
expect(container.firstChild).toMatchSnapshot();
});
});
});
describe('overrides', () => {
it('SwitchGroup.base should render correctly', () => {
const { container } = render(
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('theming', () => {
it('SwitchGroup.base should render correctly', () => {
const { container } = render(
,
{
// @ts-ignore
theme: { SwitchGroup: { styles: { base: { backgroundColor: 'red' } } } },
}
);
expect(container.firstChild).toMatchSnapshot();
});
});
describe('defaultProps', () => {
it('should render correctly for className', () => {
const { container } = render(
,
{
// @ts-ignore
theme: { SwitchGroup: { defaultProps: { className: 'test', color: 'primary' } } },
}
);
expect(container.firstChild).toMatchSnapshot();
});
});