@@ -4,7 +4,6 @@ import ManagedDialog from "./_ManagedDialog.svelte";
4
4
import NestedTestComponent from "./_NestedTestComponent.svelte" ;
5
5
import { suppressConsoleLogs } from "$lib/test-utils/suppress-console-logs" ;
6
6
import { render } from "@testing-library/svelte" ;
7
- import TestRenderer from "$lib/test-utils/TestRenderer.svelte" ;
8
7
import {
9
8
assertActiveElement ,
10
9
assertDialog ,
@@ -90,9 +89,9 @@ describe("Rendering", () => {
90
89
"should complain when an `open` prop is not a boolean" ,
91
90
suppressConsoleLogs ( async ( ) => {
92
91
expect ( ( ) =>
93
- render ( TestRenderer , {
94
- allProps : [ Dialog , { open : null , onClose : console . log , as : "div" } ] ,
95
- } )
92
+ render ( svelte `
93
+ < Dialog open={ null} on:close={ console.log} as= "div" />
94
+ ` )
96
95
) . toThrowErrorMatchingInlineSnapshot (
97
96
`"You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: null"`
98
97
) ;
@@ -359,17 +358,14 @@ describe('Composition', () => {
359
358
it (
360
359
'should be possible to open the Dialog via a Transition component' ,
361
360
suppressConsoleLogs ( async ( ) => {
362
- render (
363
- TestRenderer , {
364
- allProps : [
365
- Transition , { show : true } , [
366
- Dialog , { onClose : console . log } , [
367
- [ DialogDescription , { } , "Description" ] ,
368
- [ TestTabSentinel ]
369
- ]
370
- ]
371
- ]
372
- } )
361
+ render ( svelte `
362
+ <Transition show={true}>
363
+ <Dialog on:close={console.log}>
364
+ <DialogDescription>Description</DialogDescription>
365
+ <TestTabSentinel />
366
+ </Dialog>
367
+ </Transition>
368
+ ` )
373
369
374
370
assertDialog ( { state : DialogState . Visible } )
375
371
assertDialogDescription ( {
@@ -382,17 +378,14 @@ describe('Composition', () => {
382
378
it (
383
379
'should be possible to close the Dialog via a Transition component' ,
384
380
suppressConsoleLogs ( async ( ) => {
385
- render (
386
- TestRenderer , {
387
- allProps : [
388
- Transition , { show : false } , [
389
- Dialog , { onClose : console . log } , [
390
- [ DialogDescription , { } , "Description" ] ,
391
- [ TestTabSentinel ]
392
- ]
393
- ]
394
- ]
395
- } )
381
+ render ( svelte `
382
+ <Transition show={false}>
383
+ <Dialog on:close={console.log}>
384
+ <DialogDescription>Description</DialogDescription>
385
+ <TestTabSentinel />
386
+ </Dialog>
387
+ </Transition>
388
+ ` )
396
389
397
390
assertDialog ( { state : DialogState . InvisibleUnmounted } )
398
391
} )
@@ -404,15 +397,12 @@ describe('Keyboard interactions', () => {
404
397
it (
405
398
'should be possible to close the dialog with Escape' ,
406
399
async ( ) => {
407
- render (
408
- TestRenderer , {
409
- allProps : [
410
- [ ManagedDialog , { buttonText : "Trigger" , buttonProps : { id : "trigger" } } , [
411
- "Contents" ,
412
- [ TestTabSentinel ] ,
413
- ] ] ,
414
- ]
415
- } )
400
+ render ( svelte `
401
+ <ManagedDialog buttonText="Trigger" buttonProps={{ id: "trigger" }}>
402
+ Contents
403
+ <TestTabSentinel />
404
+ </ManagedDialog>
405
+ ` )
416
406
417
407
assertDialog ( { state : DialogState . InvisibleUnmounted } )
418
408
@@ -498,16 +488,13 @@ describe('Mouse interactions', () => {
498
488
it (
499
489
'should be possible to close a Dialog using a click on the DialogOverlay' ,
500
490
suppressConsoleLogs ( async ( ) => {
501
- render (
502
- TestRenderer , {
503
- allProps : [
504
- [ ManagedDialog , { buttonText : "Trigger" , buttonProps : { id : "trigger" } } , [
505
- [ DialogOverlay ] ,
506
- "Contents" ,
507
- [ TestTabSentinel ] ,
508
- ] ] ,
509
- ]
510
- } )
491
+ render ( svelte `
492
+ <ManagedDialog buttonText="Trigger" buttonProps={{ id: "trigger" }}>
493
+ <DialogOverlay />
494
+ Contents
495
+ <TestTabSentinel />
496
+ </ManagedDialog>
497
+ ` )
511
498
512
499
// Open dialog
513
500
await click ( document . getElementById ( 'trigger' ) )
@@ -553,15 +540,12 @@ describe('Mouse interactions', () => {
553
540
it (
554
541
'should be possible to close the dialog, and re-focus the button when we click outside on the body element' ,
555
542
suppressConsoleLogs ( async ( ) => {
556
- render (
557
- TestRenderer , {
558
- allProps : [
559
- [ ManagedDialog , { buttonText : "Trigger" , buttonProps : { id : "trigger" } } , [
560
- "Contents" ,
561
- [ TestTabSentinel ] ,
562
- ] ] ,
563
- ]
564
- } )
543
+ render ( svelte `
544
+ <ManagedDialog buttonText="Trigger" buttonProps={{ id: "trigger" }}>
545
+ Contents
546
+ <TestTabSentinel />
547
+ </ManagedDialog>
548
+ ` )
565
549
566
550
// Open dialog
567
551
await click ( getByText ( 'Trigger' ) )
0 commit comments