@@ -80,12 +80,10 @@ describe('CreateContainerModal container linking', () => {
8080 const createButton = await screen . findByRole ( 'button' , { name : / c r e a t e / i } ) ;
8181 await user . click ( createButton ) ;
8282 await waitFor ( ( ) => {
83- const request = axiosMock . history . post . find ( req => req . url . match ( / \/ a p i \/ l i b r a r i e s \/ .* \/ c o n t a i n e r s / ) ) ;
84- expect ( request ) . toBeDefined ( ) ;
83+ expect ( axiosMock . history . post ) . toHaveLength ( 1 ) ;
8584 } ) ;
86- const request = axiosMock . history . post . find ( req => req . url . match ( / \/ a p i \/ l i b r a r i e s \/ .* \/ c o n t a i n e r s / ) ) ;
87- expect ( request . url ) . toMatch ( / \/ a p i \/ l i b r a r i e s \/ .* \/ c o n t a i n e r s / ) ;
88- expect ( JSON . parse ( request . data ) ) . toEqual ( {
85+ expect ( axiosMock . history . post [ 0 ] . url ) . toMatch ( / \/ a p i \/ l i b r a r i e s \/ .* \/ c o n t a i n e r s / ) ;
86+ expect ( JSON . parse ( axiosMock . history . post [ 0 ] . data ) ) . toEqual ( {
8987 can_stand_alone : true ,
9088 container_type : 'section' ,
9189 display_name : 'Test Section' ,
@@ -116,11 +114,9 @@ describe('CreateContainerModal container linking', () => {
116114 const createButton = await screen . findByRole ( 'button' , { name : / c r e a t e / i } ) ;
117115 await user . click ( createButton ) ;
118116 await waitFor ( ( ) => {
119- const request = axiosMock . history . post . find ( req => req . url . match ( / \/ a p i \/ l i b r a r i e s \/ .* \/ c o n t a i n e r s / ) ) ;
120- expect ( request ) . toBeDefined ( ) ;
117+ expect ( axiosMock . history . post [ 0 ] . url ) . toMatch ( / \/ a p i \/ l i b r a r i e s \/ .* \/ c o n t a i n e r s / ) ;
121118 } ) ;
122- const request = axiosMock . history . post . find ( req => req . url . match ( / \/ a p i \/ l i b r a r i e s \/ .* \/ c o n t a i n e r s / ) ) ;
123- expect ( JSON . parse ( request . data ) ) . toEqual ( {
119+ expect ( JSON . parse ( axiosMock . history . post [ 0 ] . data ) ) . toEqual ( {
124120 can_stand_alone : false ,
125121 container_type : 'subsection' ,
126122 display_name : 'Test Subsection' ,
@@ -148,4 +144,4 @@ describe('CreateContainerModal container linking', () => {
148144 expect ( mockShowToast ) . toHaveBeenCalledWith ( expect . stringMatching ( / e r r o r / i) ) ;
149145 } ) ;
150146 } ) ;
151- } ) ;
147+ } ) ;
0 commit comments