@@ -6,6 +6,7 @@ describe('Modals - static helpers', () => {
6
6
const TestComp = ( ) => {
7
7
return (
8
8
< >
9
+ < Modals />
9
10
< Button
10
11
onClick = { ( ) => {
11
12
const { close } = Modals . showDialog ( {
@@ -30,18 +31,21 @@ describe('Modals - static helpers', () => {
30
31
it ( 'showPopover' , ( ) => {
31
32
const TestComp = ( ) => {
32
33
return (
33
- < Button
34
- id = "modals-show-popover"
35
- onClick = { ( ) => {
36
- const { close } = Modals . showPopover ( {
37
- opener : 'modals-show-popover' ,
38
- children : 'Popover Content' ,
39
- footer : < Bar endContent = { < Button onClick = { ( ) => close ( ) } > Close</ Button > } />
40
- } ) ;
41
- } }
42
- >
43
- Show Popover
44
- </ Button >
34
+ < >
35
+ < Modals />
36
+ < Button
37
+ id = "modals-show-popover"
38
+ onClick = { ( ) => {
39
+ const { close } = Modals . showPopover ( {
40
+ opener : 'modals-show-popover' ,
41
+ children : 'Popover Content' ,
42
+ footer : < Bar endContent = { < Button onClick = { ( ) => close ( ) } > Close</ Button > } />
43
+ } ) ;
44
+ } }
45
+ >
46
+ Show Popover
47
+ </ Button >
48
+ </ >
45
49
) ;
46
50
47
51
cy . mount ( < TestComp /> ) ;
@@ -56,18 +60,21 @@ describe('Modals - static helpers', () => {
56
60
it ( 'showResponsivePopover' , ( ) => {
57
61
const TestComp = ( ) => {
58
62
return (
59
- < Button
60
- id = "modals-show-popover"
61
- onClick = { ( ) => {
62
- const { close } = Modals . showResponsivePopover ( {
63
- opener : 'modals-show-popover' ,
64
- children : 'Popover Content' ,
65
- footer : < Bar endContent = { < Button onClick = { ( ) => close ( ) } > Close</ Button > } />
66
- } ) ;
67
- } }
68
- >
69
- Show Popover
70
- </ Button >
63
+ < >
64
+ < Modals />
65
+ < Button
66
+ id = "modals-show-popover"
67
+ onClick = { ( ) => {
68
+ const { close } = Modals . showResponsivePopover ( {
69
+ opener : 'modals-show-popover' ,
70
+ children : 'Popover Content' ,
71
+ footer : < Bar endContent = { < Button onClick = { ( ) => close ( ) } > Close</ Button > } />
72
+ } ) ;
73
+ } }
74
+ >
75
+ Show Popover
76
+ </ Button >
77
+ </ >
71
78
) ;
72
79
73
80
cy . mount ( < TestComp /> ) ;
@@ -82,17 +89,20 @@ describe('Modals - static helpers', () => {
82
89
it ( 'showMenu' , ( ) => {
83
90
const TestComp = ( ) => {
84
91
return (
85
- < Button
86
- id = "modals-show-popover"
87
- onClick = { ( ) => {
88
- Modals . showMenu ( {
89
- opener : 'modals-show-popover' ,
90
- children : < MenuItem text = "MenuItem" />
91
- } ) ;
92
- } }
93
- >
94
- Show Menu
95
- </ Button >
92
+ < >
93
+ < Modals />
94
+ < Button
95
+ id = "modals-show-popover"
96
+ onClick = { ( ) => {
97
+ Modals . showMenu ( {
98
+ opener : 'modals-show-popover' ,
99
+ children : < MenuItem text = "MenuItem" />
100
+ } ) ;
101
+ } }
102
+ >
103
+ Show Menu
104
+ </ Button >
105
+ </ >
96
106
) ;
97
107
98
108
cy . mount ( < TestComp /> ) ;
@@ -108,6 +118,7 @@ describe('Modals - static helpers', () => {
108
118
const TestComp = ( ) => {
109
119
return (
110
120
< >
121
+ < Modals />
111
122
< Button
112
123
onClick = { ( ) => {
113
124
Modals . showMessageBox ( {
@@ -131,20 +142,23 @@ describe('Modals - static helpers', () => {
131
142
it ( 'showToast' , ( ) => {
132
143
const TestComp = ( ) => {
133
144
return (
134
- < div id = "container" >
135
- < Button
136
- onClick = { ( ) => {
137
- Modals . showToast (
138
- {
139
- children : 'Toast Content'
140
- } ,
141
- document . getElementById ( 'container' )
142
- ) ;
143
- } }
144
- >
145
- Show Toast
146
- </ Button >
147
- </ div >
145
+ < >
146
+ < Modals />
147
+ < div id = "container" >
148
+ < Button
149
+ onClick = { ( ) => {
150
+ Modals . showToast (
151
+ {
152
+ children : 'Toast Content'
153
+ } ,
154
+ document . getElementById ( 'container' )
155
+ ) ;
156
+ } }
157
+ >
158
+ Show Toast
159
+ </ Button >
160
+ </ div >
161
+ </ >
148
162
) ;
149
163
} ;
150
164
cy . mount ( < TestComp /> ) ;
@@ -153,136 +167,3 @@ describe('Modals - static helpers', () => {
153
167
cy . findByText ( 'Toast Content' ) . should ( 'exist' ) ;
154
168
} ) ;
155
169
} ) ;
156
-
157
- describe ( 'Modals - hooks' , ( ) => {
158
- interface PropTypes {
159
- hookFn : any ;
160
- modalProps : any ;
161
- }
162
- const TestComponent = ( { hookFn, modalProps } : PropTypes ) => {
163
- const hook = hookFn ( ) ;
164
-
165
- return (
166
- < button
167
- onClick = { ( ) => {
168
- hook ( modalProps ) ;
169
- } }
170
- >
171
- Open Modal
172
- </ button >
173
- ) ;
174
- } ;
175
-
176
- const TestComponentClosable = ( { hookFn, modalProps } : PropTypes ) => {
177
- const hook = hookFn ( ) ;
178
-
179
- return (
180
- < Button
181
- onClick = { ( ) => {
182
- const { close } = hook ( {
183
- ...modalProps ,
184
- children : [
185
- ...modalProps ?. children ,
186
- < Button key = "btn" onClick = { ( ) => close ( ) } >
187
- Close
188
- </ Button >
189
- ]
190
- } ) ;
191
- } }
192
- >
193
- Open Modal
194
- </ Button >
195
- ) ;
196
- } ;
197
-
198
- it ( 'useShowDialog' , ( ) => {
199
- cy . mount (
200
- < TestComponentClosable
201
- hookFn = { Modals . useShowDialog }
202
- modalProps = { {
203
- children : 'Dialog Content'
204
- } }
205
- />
206
- ) ;
207
- cy . findByText ( 'Open Modal' ) . click ( ) ;
208
- cy . findByText ( 'Dialog Content' ) . should ( 'be.visible' ) ;
209
- cy . findByText ( 'Close' ) . click ( ) ;
210
- cy . findByText ( 'Dialog Content' ) . should ( 'not.exist' ) ;
211
- } ) ;
212
-
213
- it ( 'useShowPopover' , ( ) => {
214
- cy . mount (
215
- < >
216
- < span id = "opener" />
217
- < TestComponentClosable
218
- hookFn = { Modals . useShowPopover }
219
- modalProps = { { children : 'Popover Content' , opener : 'opener' } }
220
- />
221
- </ >
222
- ) ;
223
- cy . findByText ( 'Open Modal' ) . click ( ) ;
224
- cy . findByText ( 'Popover Content' ) . should ( 'be.visible' ) ;
225
- cy . findByText ( 'Close' ) . click ( ) ;
226
- cy . findByText ( 'Popover Content' ) . should ( 'not.exist' ) ;
227
- } ) ;
228
-
229
- it ( 'useShowResponsivePopover' , ( ) => {
230
- cy . mount (
231
- < >
232
- < span id = "opener" />
233
- < TestComponentClosable
234
- hookFn = { Modals . useShowResponsivePopover }
235
- modalProps = { { children : 'Popover Content' , opener : 'opener' } }
236
- />
237
- </ >
238
- ) ;
239
- cy . findByText ( 'Open Modal' ) . click ( ) ;
240
- cy . findByText ( 'Popover Content' ) . should ( 'be.visible' ) ;
241
- cy . findByText ( 'Close' ) . click ( ) ;
242
- cy . findByText ( 'Popover Content' ) . should ( 'not.exist' ) ;
243
- } ) ;
244
-
245
- it ( 'useShowMenu' , ( ) => {
246
- const TestComp = ( ) => {
247
- const showMenu = Modals . useShowMenu ( ) ;
248
- return (
249
- < div id = "container" >
250
- < Button
251
- id = "modals-show-popover"
252
- onClick = { ( ) => {
253
- showMenu (
254
- {
255
- opener : 'modals-show-popover' ,
256
- children : < MenuItem text = "MenuItem" />
257
- } ,
258
- document . getElementById ( 'container' )
259
- ) ;
260
- } }
261
- >
262
- Show Menu
263
- </ Button >
264
- </ div >
265
- ) ;
266
- } ;
267
-
268
- cy . mount ( < TestComp /> ) ;
269
-
270
- cy . findByText ( 'Show Menu' ) . click ( ) ;
271
- cy . get ( '[ui5-menu-item]' ) . click ( ) ;
272
- cy . get ( '[ui5-menu]' ) . should ( 'not.exist' ) ;
273
- } ) ;
274
-
275
- it ( 'useShowMessageBox' , ( ) => {
276
- cy . mount ( < TestComponent hookFn = { Modals . useShowMessageBox } modalProps = { { children : 'MessageBox Content' } } /> ) ;
277
- cy . findByText ( 'Open Modal' ) . click ( ) ;
278
- cy . findByText ( 'MessageBox Content' ) . should ( 'be.visible' ) ;
279
- cy . findByText ( 'OK' ) . click ( ) ;
280
- cy . findByText ( 'MessageBox Content' ) . should ( 'not.exist' ) ;
281
- } ) ;
282
-
283
- it ( 'useShowToast' , ( ) => {
284
- cy . mount ( < TestComponent hookFn = { Modals . useShowToast } modalProps = { { children : 'Toast Content' } } /> ) ;
285
- cy . findByText ( 'Open Modal' ) . click ( ) ;
286
- cy . findByText ( 'Toast Content' ) . should ( 'exist' ) ;
287
- } ) ;
288
- } ) ;
0 commit comments