import * as React from 'react';
import { renderHook } from '@testing-library/react-hooks';
import { Box } from '../../Box';
import { Modal } from '../index';
import render from '../../utils/_tests/render';
describe('props', () => {
it('should render correctly', () => {
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return Toggle;
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
it('should assign a ref', () => {
const ref = React.createRef();
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return (
Toggle
);
}
render();
expect(ref.current).toMatchSnapshot();
});
it('should render correctly when disabled is set', () => {
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return (
Toggle
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
it('should render correctly when focusable is set', () => {
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return (
Toggle
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
});
describe('composition', () => {
describe('as', () => {
it('should render correctly', () => {
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return (
Toggle
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
});
describe('hook', () => {
it('should return with Modal.Disclosure props', () => {
const { result } = renderHook(() => {
const modal = Modal.useState({ baseId: 'test' });
return Modal.Disclosure.useProps(modal);
});
expect(result.current).toMatchSnapshot();
});
});
describe('render props', () => {
it('should render correctly', () => {
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return (
{(ModalDisclosureProps) => Hello world
}
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
});
});
describe('overrides', () => {
it('Modal.Disclosure.base should render correctly', () => {
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return (
Toggle
);
}
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
});
describe('theming', () => {
it('Modal.Disclosure.base should render correctly', () => {
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return Toggle;
}
const { container } = render(, {
theme: { Modal: { Disclosure: { styles: { base: { backgroundColor: 'red' } } } } },
});
expect(container.firstChild).toMatchSnapshot();
});
});
describe('defaultProps', () => {
it('should render correctly for className', () => {
function Component() {
const modal = Modal.useState({ baseId: 'test' });
return Toggle;
}
const { container } = render(, {
theme: { Modal: { Disclosure: { defaultProps: { className: 'red' } } } },
});
expect(container.firstChild).toMatchSnapshot();
});
});