22import { CSSProperties } from "react" ;
33import { fireEvent , render } from "@testing-library/react" ;
44
5- import { DropdownMenu } from "../DropdownMenu" ;
5+ import { DropdownMenu , DropdownMenuProps } from "../DropdownMenu" ;
66import { MenuItem } from "../MenuItem" ;
77
88const getById = ( id : string ) => {
@@ -14,25 +14,23 @@ const getById = (id: string) => {
1414 return el ;
1515} ;
1616
17- const PROPS = {
17+ const PROPS : Omit < DropdownMenuProps , "items" > = {
1818 id : "dropdown" ,
1919 children : "Dropdown" ,
2020} ;
2121
2222describe ( "DropdownMenu" , ( ) => {
2323 it ( "should render correctly with a list of strings, numbers, ListItemProps, ReactElement, or a mixture of all" , ( ) => {
2424 const items1 = [ "Item 1" , "Item 2" , "Item 3" ] ;
25- const { container, rerender } = render (
26- < DropdownMenu { ...PROPS } items = { items1 } />
27- ) ;
28- expect ( container ) . toMatchSnapshot ( ) ;
25+ const { rerender } = render ( < DropdownMenu { ...PROPS } items = { items1 } /> ) ;
26+ expect ( document . body ) . toMatchSnapshot ( ) ;
2927
3028 fireEvent . click ( getById ( "dropdown" ) ) ;
31- expect ( container ) . toMatchSnapshot ( ) ;
29+ expect ( document . body ) . toMatchSnapshot ( ) ;
3230
3331 const items2 = [ 0 , 1 , 2 , 3 , 4 ] ;
3432 rerender ( < DropdownMenu { ...PROPS } items = { items2 } /> ) ;
35- expect ( container ) . toMatchSnapshot ( ) ;
33+ expect ( document . body ) . toMatchSnapshot ( ) ;
3634
3735 const items3 = [
3836 {
@@ -42,7 +40,7 @@ describe("DropdownMenu", () => {
4240 { rightAddon : < i > icon</ i > , children : "Item 3" } ,
4341 ] ;
4442 rerender ( < DropdownMenu { ...PROPS } items = { items3 } /> ) ;
45- expect ( container ) . toMatchSnapshot ( ) ;
43+ expect ( document . body ) . toMatchSnapshot ( ) ;
4644
4745 // Note: no key required
4846 const items4 = [
@@ -54,7 +52,7 @@ describe("DropdownMenu", () => {
5452 4 ,
5553 ] ;
5654 rerender ( < DropdownMenu { ...PROPS } items = { items4 } /> ) ;
57- expect ( container ) . toMatchSnapshot ( ) ;
55+ expect ( document . body ) . toMatchSnapshot ( ) ;
5856 } ) ;
5957
6058 it ( "should pass the menuStyle and menuClassName props to the menu correctly" , ( ) => {
0 commit comments