import * as React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { DropdownMenu } from '../index'; import { Button } from '../../Button'; import { Link } from '../../Link'; import render from '../../utils/_tests/render'; describe('props', () => { it('should render correctly', () => { const { container } = render( Edit Share Rename Delete } visible > ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for an invisible dropdown menu', () => { const { container } = render( Edit Share Rename Delete } > ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for CSS props', () => { const { container } = render( Edit Share Rename Delete } > ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with groups', () => { const { container } = render( Edit Share Rename Delete Test } visible > ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for an uncontrolled option group', () => { const { container } = render( Ascending Descending Australia United States India } visible > ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly for a controlled option group', () => { const { container } = render(() => { const [sortBy, setSortBy] = React.useState | string>('asc'); const [countries, setCountries] = React.useState | string>(['australia', 'india']); return ( setSortBy(value)} value={sortBy} title="Sort by" type="radio" > Ascending Descending setCountries(value)} value={countries} title="Countries" type="checkbox" > Australia United States India } visible > ); }); expect(container.firstChild).toMatchSnapshot(); }); }); describe('overrides', () => { it('DropdownMenu.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete } > ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Popover.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete } > ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Button.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete } > ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Divider.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete Test } > ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Group.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete Test } > ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Item.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete Test } > ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('theming', () => { it('DropdownMenu.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete } > , { theme: { DropdownMenu: { styles: { base: { backgroundColor: 'red' } } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Popover.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete } > , { theme: { DropdownMenu: { Popover: { styles: { base: { backgroundColor: 'red' } } } } } } ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Button.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete } > , { theme: { DropdownMenu: { Button: { styles: { base: { backgroundColor: 'red' } } } } } } ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Divider.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete Test } > , { theme: { DropdownMenu: { Divider: { styles: { base: { backgroundColor: 'red' } } } } } } ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Group.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete Test } > , { theme: { DropdownMenu: { Group: { styles: { base: { backgroundColor: 'red' } } } } } } ); expect(container.firstChild).toMatchSnapshot(); }); it('DropdownMenu.Item.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete Test } > , { theme: { DropdownMenu: { Item: { styles: { base: { backgroundColor: 'red' } } } } } } ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('defaultProps', () => { it('should render correctly for className', () => { const { container } = render( Edit Share Rename Delete } > , { theme: { DropdownMenu: { defaultProps: { className: 'test', color: 'primary' } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); });