@@ -134,6 +134,74 @@ describe('.toBeVisible', () => {
134
134
} )
135
135
} )
136
136
137
+ describe ( 'when the <details /> inner text does not have an enclosing element' , ( ) => {
138
+ describe ( 'when the details is not opened' , ( ) => {
139
+ beforeEach ( ( ) => {
140
+ subject = render ( `
141
+ <details>
142
+ <summary>Title of hidden innerText</summary>
143
+ hidden innerText
144
+ </details>
145
+ ` )
146
+ } )
147
+
148
+ it ( 'returns false to the details content' , ( ) => {
149
+ expect ( subject . container . querySelector ( 'details' ) ) . not . toBeVisible ( )
150
+ } )
151
+
152
+ it ( 'returns true to the details summary' , ( ) => {
153
+ expect ( subject . container . querySelector ( 'summary' ) ) . toBeVisible ( )
154
+ } )
155
+
156
+ describe ( 'when the user clicks on the summary' , ( ) => {
157
+ beforeEach ( ( ) => subject . container . querySelector ( 'summary' ) . click ( ) )
158
+
159
+ it ( 'returns true to the details content' , ( ) => {
160
+ expect ( subject . container . querySelector ( 'details' ) ) . toBeVisible ( )
161
+ } )
162
+
163
+ it ( 'returns true to the details summary' , ( ) => {
164
+ expect ( subject . container . querySelector ( 'summary' ) ) . toBeVisible ( )
165
+ } )
166
+ } )
167
+ } )
168
+
169
+ describe ( 'when the details is opened' , ( ) => {
170
+ beforeEach ( ( ) => {
171
+ subject = render ( `
172
+ <details open>
173
+ <summary>Title of visible innerText</summary>
174
+ visible <small>innerText</small>
175
+ </details>
176
+ ` )
177
+ } )
178
+
179
+ it ( 'returns true to the details content' , ( ) => {
180
+ expect ( subject . container . querySelector ( 'details' ) ) . toBeVisible ( )
181
+ } )
182
+
183
+ it ( 'returns true to inner small content' , ( ) => {
184
+ expect ( subject . container . querySelector ( 'small' ) ) . toBeVisible ( )
185
+ } )
186
+
187
+ describe ( 'when the user clicks on the summary' , ( ) => {
188
+ beforeEach ( ( ) => subject . container . querySelector ( 'summary' ) . click ( ) )
189
+
190
+ it ( 'returns false to the details content' , ( ) => {
191
+ expect ( subject . container . querySelector ( 'details' ) ) . not . toBeVisible ( )
192
+ } )
193
+
194
+ it ( 'returns false to the inner small content' , ( ) => {
195
+ expect ( subject . container . querySelector ( 'small' ) ) . not . toBeVisible ( )
196
+ } )
197
+
198
+ it ( 'returns true to the details summary' , ( ) => {
199
+ expect ( subject . container . querySelector ( 'summary' ) ) . toBeVisible ( )
200
+ } )
201
+ } )
202
+ } )
203
+ } )
204
+
137
205
describe ( 'with a nested <details /> element' , ( ) => {
138
206
describe ( 'when the nested <details /> is opened' , ( ) => {
139
207
beforeEach ( ( ) => {
@@ -247,6 +315,113 @@ describe('.toBeVisible', () => {
247
315
) . toBeVisible ( )
248
316
} )
249
317
} )
318
+
319
+ describe ( 'with nested details (unenclosed outer, enclosed inner)' , ( ) => {
320
+ describe ( 'when both outer and inner are opened' , ( ) => {
321
+ beforeEach ( ( ) => {
322
+ subject = render ( `
323
+ <details open>
324
+ <summary>Title of outer unenclosed</summary>
325
+ Unenclosed innerText
326
+ <details open>
327
+ <summary>Title of inner enclosed</summary>
328
+ <div>Enclosed innerText</div>
329
+ </details>
330
+ </details>
331
+ ` )
332
+ } )
333
+
334
+ it ( 'returns true to outer unenclosed innerText' , ( ) => {
335
+ expect ( subject . container . querySelector ( 'details' ) ) . toBeVisible ( )
336
+ } )
337
+
338
+ it ( 'returns true to outer summary' , ( ) => {
339
+ expect ( subject . container . querySelector ( 'summary' ) ) . toBeVisible ( )
340
+ } )
341
+
342
+ it ( 'returns true to inner enclosed innerText' , ( ) => {
343
+ expect (
344
+ subject . container . querySelector ( 'details > details > div' ) ,
345
+ ) . toBeVisible ( )
346
+ } )
347
+
348
+ it ( 'returns true to inner summary' , ( ) => {
349
+ expect (
350
+ subject . container . querySelector ( 'details > details > summary' ) ,
351
+ ) . toBeVisible ( )
352
+ } )
353
+ } )
354
+
355
+ describe ( 'when outer is opened and inner is not opened' , ( ) => {
356
+ beforeEach ( ( ) => {
357
+ subject = render ( `
358
+ <details open>
359
+ <summary>Title of outer unenclosed</summary>
360
+ Unenclosed innerText
361
+ <details>
362
+ <summary>Title of inner enclosed</summary>
363
+ <div>Enclosed innerText</div>
364
+ </details>
365
+ </details>
366
+ ` )
367
+ } )
368
+
369
+ it ( 'returns true to outer unenclosed innerText' , ( ) => {
370
+ expect ( subject . container . querySelector ( 'details' ) ) . toBeVisible ( )
371
+ } )
372
+
373
+ it ( 'returns true to outer summary' , ( ) => {
374
+ expect ( subject . container . querySelector ( 'summary' ) ) . toBeVisible ( )
375
+ } )
376
+
377
+ it ( 'returns false to inner enclosed innerText' , ( ) => {
378
+ expect (
379
+ subject . container . querySelector ( 'details > details > div' ) ,
380
+ ) . not . toBeVisible ( )
381
+ } )
382
+
383
+ it ( 'returns true to inner summary' , ( ) => {
384
+ expect (
385
+ subject . container . querySelector ( 'details > details > summary' ) ,
386
+ ) . toBeVisible ( )
387
+ } )
388
+ } )
389
+
390
+ describe ( 'when outer is not opened and inner is opened' , ( ) => {
391
+ beforeEach ( ( ) => {
392
+ subject = render ( `
393
+ <details>
394
+ <summary>Title of outer unenclosed</summary>
395
+ Unenclosed innerText
396
+ <details open>
397
+ <summary>Title of inner enclosed</summary>
398
+ <div>Enclosed innerText</div>
399
+ </details>
400
+ </details>
401
+ ` )
402
+ } )
403
+
404
+ it ( 'returns true to outer unenclosed innerText' , ( ) => {
405
+ expect ( subject . container . querySelector ( 'details' ) ) . not . toBeVisible ( )
406
+ } )
407
+
408
+ it ( 'returns true to outer summary' , ( ) => {
409
+ expect ( subject . container . querySelector ( 'summary' ) ) . toBeVisible ( )
410
+ } )
411
+
412
+ it ( 'returns false to inner enclosed innerText' , ( ) => {
413
+ expect (
414
+ subject . container . querySelector ( 'details > details > div' ) ,
415
+ ) . not . toBeVisible ( )
416
+ } )
417
+
418
+ it ( 'returns true to inner summary' , ( ) => {
419
+ expect (
420
+ subject . container . querySelector ( 'details > details > summary' ) ,
421
+ ) . not . toBeVisible ( )
422
+ } )
423
+ } )
424
+ } )
250
425
} )
251
426
} )
252
427
} )
0 commit comments