import * as React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { ActionButtons } from '../ActionButtons'; import { Button } from '../../Button'; 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 with addon buttons', () => { const { container } = render(Addon} />); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with cancel props', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with cancel text', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with isLoading', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with onClickSubmit', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with onClickCancel', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with palette', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with submitProps', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with submitText', () => { const { container } = render(); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with type', () => { 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 ActionButtons props', () => { const { result } = renderHook(() => ActionButtons.useProps()); expect(result.current).toMatchSnapshot(); }); }); describe('render props', () => { it('should render correctly', () => { const { container } = render( {(actionButtonsProps) =>
} ); expect(container.firstChild).toMatchSnapshot(); }); }); }); describe('overrides', () => { it('ActionButtons.base should render correctly', () => { const { container } = render( ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('theming', () => { it('ActionButtons.base should render correctly', () => { const { container } = render(, { theme: { ActionButtons: { styles: { base: { backgroundColor: 'red' } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); }); describe('defaultProps', () => { it('should render correctly', () => { const { container } = render(, { theme: { ActionButtons: { defaultProps: { className: 'test' } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with addon buttons', () => { const { container } = render(, { theme: { ActionButtons: { defaultProps: { addonButtons: } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with cancel props', () => { const { container } = render(, { theme: { ActionButtons: { defaultProps: { cancelProps: { disabled: true, isLoading: true } } } }, }); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with cancel text', () => { const { container } = render(, { theme: { ActionButtons: { defaultProps: { cancelText: 'Close' } } }, }); expect(container.firstChild).toMatchSnapshot(); }); });