@@ -18,7 +18,7 @@ const prefix = 'cds';
18
18
describe ( 'Modal' , ( ) => {
19
19
it ( 'should add extra classes that are passed via className' , ( ) => {
20
20
render (
21
- < Modal data-testid = "modal-1" className = "custom-class" >
21
+ < Modal open data-testid = "modal-1" className = "custom-class" >
22
22
< p >
23
23
Custom domains direct requests for your apps in this Cloud Foundry
24
24
organization to a URL that you own. A custom domain can be a shared
@@ -37,7 +37,7 @@ describe('Modal', () => {
37
37
38
38
it ( 'should set label if one is passed via props' , ( ) => {
39
39
render (
40
- < Modal modalLabel = "Account resources" >
40
+ < Modal open modalLabel = "Account resources" >
41
41
< p >
42
42
Custom domains direct requests for your apps in this Cloud Foundry
43
43
organization to a URL that you own. A custom domain can be a shared
@@ -56,7 +56,7 @@ describe('Modal', () => {
56
56
57
57
it ( 'should set modal heading if one is passed via props' , ( ) => {
58
58
render (
59
- < Modal modalHeading = "Add a custom domain" >
59
+ < Modal open modalHeading = "Add a custom domain" >
60
60
< p >
61
61
Custom domains direct requests for your apps in this Cloud Foundry
62
62
organization to a URL that you own. A custom domain can be a shared
@@ -75,7 +75,7 @@ describe('Modal', () => {
75
75
76
76
it ( 'should not be a passive modal by default' , ( ) => {
77
77
render (
78
- < Modal data-testid = "modal-2" >
78
+ < Modal open data-testid = "modal-2" >
79
79
< p >
80
80
Custom domains direct requests for your apps in this Cloud Foundry
81
81
organization to a URL that you own. A custom domain can be a shared
@@ -94,7 +94,7 @@ describe('Modal', () => {
94
94
95
95
it ( 'should be a passive modal when passiveModal is passed' , ( ) => {
96
96
render (
97
- < Modal data-testid = "modal-3" passiveModal >
97
+ < Modal open data-testid = "modal-3" passiveModal >
98
98
< p >
99
99
Custom domains direct requests for your apps in this Cloud Foundry
100
100
organization to a URL that you own. A custom domain can be a shared
@@ -115,7 +115,7 @@ describe('Modal', () => {
115
115
116
116
it ( 'should set id if one is passed via props' , ( ) => {
117
117
render (
118
- < Modal id = "custom-modal-id" data-testid = "modal-4" >
118
+ < Modal open id = "custom-modal-id" data-testid = "modal-4" >
119
119
< p >
120
120
Custom domains direct requests for your apps in this Cloud Foundry
121
121
organization to a URL that you own. A custom domain can be a shared
@@ -137,7 +137,7 @@ describe('Modal', () => {
137
137
138
138
it ( 'should not place the svg icon in the accessibility tree' , ( ) => {
139
139
render (
140
- < Modal >
140
+ < Modal open >
141
141
< p >
142
142
Custom domains direct requests for your apps in this Cloud Foundry
143
143
organization to a URL that you own. A custom domain can be a shared
@@ -159,7 +159,7 @@ describe('Modal', () => {
159
159
160
160
it ( 'should not make the icon tabbable' , ( ) => {
161
161
render (
162
- < Modal >
162
+ < Modal open >
163
163
< p >
164
164
Custom domains direct requests for your apps in this Cloud Foundry
165
165
organization to a URL that you own. A custom domain can be a shared
@@ -181,7 +181,7 @@ describe('Modal', () => {
181
181
182
182
it ( 'enables primary button by default' , ( ) => {
183
183
render (
184
- < Modal primaryButtonText = "Primary button text" >
184
+ < Modal open primaryButtonText = "Primary button text" >
185
185
< p >
186
186
Custom domains direct requests for your apps in this Cloud Foundry
187
187
organization to a URL that you own. A custom domain can be a shared
@@ -200,7 +200,7 @@ describe('Modal', () => {
200
200
201
201
it ( 'disables primary button is disablePrimaryButton prop is passed' , ( ) => {
202
202
render (
203
- < Modal primaryButtonText = "Primary button text" primaryButtonDisabled >
203
+ < Modal open primaryButtonText = "Primary button text" primaryButtonDisabled >
204
204
< p >
205
205
Custom domains direct requests for your apps in this Cloud Foundry
206
206
organization to a URL that you own. A custom domain can be a shared
@@ -220,6 +220,7 @@ describe('Modal', () => {
220
220
it ( 'should set button text when passed via props' , ( ) => {
221
221
render (
222
222
< Modal
223
+ open
223
224
primaryButtonText = "Primary button text"
224
225
secondaryButtonText = "Secondary button text" >
225
226
< p >
@@ -242,6 +243,7 @@ describe('Modal', () => {
242
243
it ( 'should allow you to pass a node for the primary and secondary buttons' , ( ) => {
243
244
render (
244
245
< Modal
246
+ open
245
247
primaryButtonText = { < span data-testid = "primary-node" > testing</ span > }
246
248
secondaryButtonText = { < span data-testid = "secondary-node" > testing</ span > } >
247
249
< p >
@@ -264,6 +266,7 @@ describe('Modal', () => {
264
266
it ( 'should support 2 secondary buttons' , ( ) => {
265
267
render (
266
268
< Modal
269
+ open
267
270
primaryButtonText = "Primary button text"
268
271
secondaryButtons = { [
269
272
{
@@ -294,7 +297,7 @@ describe('Modal', () => {
294
297
295
298
it ( 'has the expected attributes when alert prop is passed' , ( ) => {
296
299
render (
297
- < Modal alert >
300
+ < Modal open alert >
298
301
< p >
299
302
Custom domains direct requests for your apps in this Cloud Foundry
300
303
organization to a URL that you own. A custom domain can be a shared
@@ -315,6 +318,7 @@ describe('Modal', () => {
315
318
it ( 'renders a danger button and appropriate classes when danger prop is passed' , ( ) => {
316
319
render (
317
320
< Modal
321
+ open
318
322
danger
319
323
primaryButtonText = "Danger button text"
320
324
data-testid = "modal-5" >
@@ -342,6 +346,7 @@ describe('Modal', () => {
342
346
it ( 'disables buttons when inline loading status is active' , ( ) => {
343
347
render (
344
348
< Modal
349
+ open
345
350
id = "custom-modal-id"
346
351
data-testid = "modal-4"
347
352
loadingStatus = "active"
@@ -371,6 +376,7 @@ describe('Modal', () => {
371
376
it ( 'should respect decorator prop' , ( ) => {
372
377
const { container } = render (
373
378
< Modal
379
+ open
374
380
danger
375
381
primaryButtonText = "Danger button text"
376
382
data-testid = "modal-5"
@@ -385,6 +391,7 @@ describe('Modal', () => {
385
391
const spy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
386
392
const { container } = render (
387
393
< Modal
394
+ open
388
395
danger
389
396
primaryButtonText = "Danger button text"
390
397
data-testid = "modal-5"
@@ -487,23 +494,25 @@ describe('Modal', () => {
487
494
Launch Modal
488
495
</ button >
489
496
< Modal
497
+ open
490
498
launcherButtonRef = { launcherButtonRef }
491
499
primaryButtonText = "Save"
492
- secondaryButtonText = "Cancel" >
500
+ secondaryButtonText = "Cancel"
501
+ data-testid = "modal" >
493
502
< p > Modal Content</ p >
494
503
</ Modal >
495
504
</ >
496
505
) ;
497
506
498
507
const launcherButton = screen . getByTestId ( 'launcher-button' ) ;
508
+ const saveButton = screen . getByRole ( 'button' , { name : / S a v e / } ) ;
499
509
500
- expect ( launcherButton ) . not . toHaveFocus ( ) ;
501
- expect ( document . body ) . toHaveFocus ( ) ;
510
+ expect ( saveButton ) . toHaveFocus ( ) ;
502
511
503
512
jest . runAllTimers ( ) ;
504
513
505
514
expect ( launcherButton ) . not . toHaveFocus ( ) ;
506
- expect ( document . body ) . toHaveFocus ( ) ;
515
+ expect ( saveButton ) . toHaveFocus ( ) ;
507
516
508
517
jest . useRealTimers ( ) ;
509
518
} ) ;
0 commit comments