import * as React from 'react'; import { renderHook } from '@testing-library/react-hooks'; import { Menu } 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 ); 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 ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with uncontrolled option groups', () => { const { container } = render( Ascending Descending Australia United States India ); expect(container.firstChild).toMatchSnapshot(); }); it('should render correctly with controlled option groups', () => { 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 ); }); expect(container.firstChild).toMatchSnapshot(); }); }); describe('overrides', () => { it('Menu.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete ); expect(container.firstChild).toMatchSnapshot(); }); it('Menu.Divider.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete ); expect(container.firstChild).toMatchSnapshot(); }); it('Menu.Group.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete ); expect(container.firstChild).toMatchSnapshot(); }); it('Menu.Item.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete ); expect(container.firstChild).toMatchSnapshot(); }); }); describe('theming', () => { it('Menu.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete , { theme: { Menu: { styles: { base: { backgroundColor: 'red' } } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); it('Menu.Divider.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete , { theme: { Menu: { Divider: { styles: { base: { backgroundColor: 'red' } } } } } } ); expect(container.firstChild).toMatchSnapshot(); }); it('Menu.Group.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete , { theme: { Menu: { Group: { styles: { base: { backgroundColor: 'red' } } } } } } ); expect(container.firstChild).toMatchSnapshot(); }); it('Menu.Item.styles.base should render correctly', () => { const { container } = render( Edit Share Rename Delete , { theme: { Menu: { 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: { Menu: { defaultProps: { className: 'test', color: 'primary' } } }, } ); expect(container.firstChild).toMatchSnapshot(); }); });