1- import { cleanup , render as HTMLRender , waitFor } from '@testing-library/react'
1+ import { render as HTMLRender , waitFor } from '@testing-library/react'
22import userEvent from '@testing-library/user-event'
3- import 'babel-polyfill'
43import { axe , toHaveNoViolations } from 'jest-axe'
54import React from 'react'
65import theme from '../theme'
76import { ActionMenu , ActionList , BaseStyles , ThemeProvider , SSRProvider } from '..'
87import { behavesAsComponent , checkExports , checkStoriesForAxeViolations } from '../utils/testing'
98import { SingleSelection , MixedSelection } from '../stories/ActionMenu/examples.stories'
10- import '@testing-library/jest-dom'
119expect . extend ( toHaveNoViolations )
1210
1311function Example ( ) : JSX . Element {
@@ -55,7 +53,6 @@ describe('ActionMenu', () => {
5553 await user . click ( button )
5654
5755 expect ( component . getByRole ( 'menu' ) ) . toBeInTheDocument ( )
58- cleanup ( )
5956 } )
6057
6158 it ( 'should open Menu on MenuButton keypress' , async ( ) => {
@@ -67,7 +64,6 @@ describe('ActionMenu', () => {
6764 await user . keyboard ( '{Enter}' )
6865
6966 expect ( component . getByRole ( 'menu' ) ) . toBeInTheDocument ( )
70- cleanup ( )
7167 } )
7268
7369 it ( 'should close Menu on selecting an action with click' , async ( ) => {
@@ -81,7 +77,6 @@ describe('ActionMenu', () => {
8177 await user . click ( menuItems [ 0 ] )
8278
8379 expect ( component . queryByRole ( 'menu' ) ) . toBeNull ( )
84- cleanup ( )
8580 } )
8681
8782 it ( 'should close Menu on selecting an action with Enter' , async ( ) => {
@@ -96,7 +91,6 @@ describe('ActionMenu', () => {
9691 await user . keyboard ( '{Enter}' )
9792
9893 expect ( component . queryByRole ( 'menu' ) ) . toBeNull ( )
99- cleanup ( )
10094 } )
10195
10296 it ( 'should not close Menu if event is prevented' , async ( ) => {
@@ -111,8 +105,6 @@ describe('ActionMenu', () => {
111105
112106 // menu should still be open
113107 expect ( component . getByRole ( 'menu' ) ) . toBeInTheDocument ( )
114-
115- cleanup ( )
116108 } )
117109
118110 it ( 'should be able to select an Item with selectionVariant' , async ( ) => {
@@ -133,7 +125,6 @@ describe('ActionMenu', () => {
133125 // open menu again and check if the first option is checked
134126 await user . click ( button )
135127 expect ( component . getAllByRole ( 'menuitemradio' ) [ 0 ] ) . toHaveAttribute ( 'aria-checked' , 'true' )
136- cleanup ( )
137128 } )
138129
139130 it ( 'should assign the right roles with groups & mixed selectionVariant' , async ( ) => {
@@ -149,8 +140,6 @@ describe('ActionMenu', () => {
149140
150141 expect ( component . getByLabelText ( 'Status' ) ) . toHaveAttribute ( 'role' , 'menuitemradio' )
151142 expect ( component . getByLabelText ( 'Clear Group by' ) ) . toHaveAttribute ( 'role' , 'menuitem' )
152-
153- cleanup ( )
154143 } )
155144
156145 it ( 'should keep focus on Button when menu is opened with click' , async ( ) => {
@@ -164,8 +153,6 @@ describe('ActionMenu', () => {
164153 await user . click ( button )
165154 expect ( component . queryByRole ( 'menu' ) ) . toBeInTheDocument ( )
166155 expect ( document . activeElement ) . toEqual ( button )
167-
168- cleanup ( )
169156 } )
170157
171158 it ( 'should select first element when ArrowDown is pressed after opening Menu with click' , async ( ) => {
@@ -181,7 +168,6 @@ describe('ActionMenu', () => {
181168 await user . keyboard ( '{ArrowDown}' )
182169
183170 expect ( component . getAllByRole ( 'menuitem' ) [ 0 ] ) . toEqual ( document . activeElement )
184- cleanup ( )
185171 } )
186172
187173 it ( 'should select last element when ArrowUp is pressed after opening Menu with click' , async ( ) => {
@@ -199,7 +185,6 @@ describe('ActionMenu', () => {
199185 await user . keyboard ( '{ArrowUp}' )
200186
201187 expect ( component . getAllByRole ( 'menuitem' ) . pop ( ) ) . toEqual ( document . activeElement )
202- cleanup ( )
203188 } )
204189
205190 it ( 'should close the menu if Tab is pressed and move to next element' , async ( ) => {
@@ -225,15 +210,12 @@ describe('ActionMenu', () => {
225210 expect ( document . activeElement ) . toEqual ( component . getByPlaceholderText ( 'next focusable element' ) )
226211 expect ( component . queryByRole ( 'menu' ) ) . not . toBeInTheDocument ( )
227212 } )
228-
229- cleanup ( )
230213 } )
231214
232215 it ( 'should have no axe violations' , async ( ) => {
233216 const { container} = HTMLRender ( < Example /> )
234217 const results = await axe ( container )
235218 expect ( results ) . toHaveNoViolations ( )
236- cleanup ( )
237219 } )
238220
239221 checkStoriesForAxeViolations ( 'ActionMenu/fixtures' )
0 commit comments