1
1
import React from 'react' ;
2
2
3
3
import { ErrorPage } from '@edx/frontend-platform/react' ;
4
- import { ModalDialog , Modal } from '@openedx/paragon' ;
4
+ import { ModalDialog } from '@openedx/paragon' ;
5
5
import { shallow } from '@edx/react-unit-test-utils' ;
6
6
7
7
import PageLoading from '@src/generic/PageLoading' ;
@@ -13,7 +13,6 @@ jest.mock('@edx/frontend-platform/react', () => ({ ErrorPage: 'ErrorPage' }));
13
13
14
14
jest . mock ( '@openedx/paragon' , ( ) => jest . requireActual ( '@edx/react-unit-test-utils' )
15
15
. mockComponents ( {
16
- Modal : 'Modal' ,
17
16
ModalDialog : {
18
17
Body : 'ModalDialog.Body' ,
19
18
} ,
@@ -138,7 +137,7 @@ describe('ContentIFrame Component', () => {
138
137
} ) ;
139
138
it ( 'does not display modal if modalOptions returns isOpen: false' , ( ) => {
140
139
el = shallow ( < ContentIFrame { ...props } /> ) ;
141
- expect ( el . instance . findByType ( Modal ) . length ) . toEqual ( 0 ) ;
140
+ expect ( el . instance . findByType ( ModalDialog ) . length ) . toEqual ( 0 ) ;
142
141
} ) ;
143
142
describe ( 'if modalOptions.isOpen' , ( ) => {
144
143
const testModalOpenAndHandleClose = ( ) => {
@@ -193,30 +192,32 @@ describe('ContentIFrame Component', () => {
193
192
beforeEach ( ( ) => {
194
193
hooks . useModalIFrameData . mockReturnValueOnce ( { ...modalIFrameData , modalOptions : modalOptions . withBody } ) ;
195
194
el = shallow ( < ContentIFrame { ...props } /> ) ;
196
- [ component ] = el . instance . findByType ( Modal ) ;
195
+ [ component ] = el . instance . findByType ( ModalDialog ) ;
197
196
} ) ;
198
197
it ( 'displays Modal with div wrapping provided body content if modal.body is provided' , ( ) => {
199
- expect ( component . props . body ) . toEqual ( < div className = "unit-modal" > { modalOptions . withBody . body } </ div > ) ;
198
+ const content = component . findByType ( ModalDialog . Body ) [ 0 ] . children [ 0 ] ;
199
+ expect ( content . matches ( shallow ( < div className = "unit-modal" > { modalOptions . withBody . body } </ div > ) ) ) . toEqual ( true ) ;
200
200
} ) ;
201
201
testModalOpenAndHandleClose ( ) ;
202
202
} ) ;
203
203
describe ( 'url modal' , ( ) => {
204
204
beforeEach ( ( ) => {
205
205
hooks . useModalIFrameData . mockReturnValueOnce ( { ...modalIFrameData , modalOptions : modalOptions . withUrl } ) ;
206
206
el = shallow ( < ContentIFrame { ...props } /> ) ;
207
- [ component ] = el . instance . findByType ( Modal ) ;
207
+ [ component ] = el . instance . findByType ( ModalDialog ) ;
208
208
} ) ;
209
209
testModalOpenAndHandleClose ( ) ;
210
210
it ( 'displays Modal with iframe to provided url if modal.body is not provided' , ( ) => {
211
- expect ( component . props . body ) . toEqual (
211
+ const content = component . findByType ( ModalDialog . Body ) [ 0 ] . children [ 0 ] ;
212
+ expect ( content . matches ( shallow (
212
213
< iframe
213
214
title = { modalOptions . withUrl . title }
214
215
allow = { IFRAME_FEATURE_POLICY }
215
216
frameBorder = "0"
216
217
src = { modalOptions . withUrl . url }
217
218
style = { { width : '100%' , height : modalOptions . withUrl . height } }
218
219
/> ,
219
- ) ;
220
+ ) ) ) . toEqual ( true ) ;
220
221
} ) ;
221
222
} ) ;
222
223
} ) ;
0 commit comments