Skip to content

Commit 2332f36

Browse files
daveparrgossiaux
authored andcommitted
Remove TestRenderer from dialog test
1 parent 0314c69 commit 2332f36

File tree

1 file changed

+38
-54
lines changed

1 file changed

+38
-54
lines changed

src/lib/components/dialog/dialog.test.ts

Lines changed: 38 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import ManagedDialog from "./_ManagedDialog.svelte";
44
import NestedTestComponent from "./_NestedTestComponent.svelte";
55
import { suppressConsoleLogs } from "$lib/test-utils/suppress-console-logs";
66
import { render } from "@testing-library/svelte";
7-
import TestRenderer from "$lib/test-utils/TestRenderer.svelte";
87
import {
98
assertActiveElement,
109
assertDialog,
@@ -90,9 +89,9 @@ describe("Rendering", () => {
9089
"should complain when an `open` prop is not a boolean",
9190
suppressConsoleLogs(async () => {
9291
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+
`)
9695
).toThrowErrorMatchingInlineSnapshot(
9796
`"You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: null"`
9897
);
@@ -359,17 +358,14 @@ describe('Composition', () => {
359358
it(
360359
'should be possible to open the Dialog via a Transition component',
361360
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+
`)
373369

374370
assertDialog({ state: DialogState.Visible })
375371
assertDialogDescription({
@@ -382,17 +378,14 @@ describe('Composition', () => {
382378
it(
383379
'should be possible to close the Dialog via a Transition component',
384380
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+
`)
396389

397390
assertDialog({ state: DialogState.InvisibleUnmounted })
398391
})
@@ -404,15 +397,12 @@ describe('Keyboard interactions', () => {
404397
it(
405398
'should be possible to close the dialog with Escape',
406399
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+
`)
416406

417407
assertDialog({ state: DialogState.InvisibleUnmounted })
418408

@@ -498,16 +488,13 @@ describe('Mouse interactions', () => {
498488
it(
499489
'should be possible to close a Dialog using a click on the DialogOverlay',
500490
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+
`)
511498

512499
// Open dialog
513500
await click(document.getElementById('trigger'))
@@ -553,15 +540,12 @@ describe('Mouse interactions', () => {
553540
it(
554541
'should be possible to close the dialog, and re-focus the button when we click outside on the body element',
555542
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+
`)
565549

566550
// Open dialog
567551
await click(getByText('Trigger'))

0 commit comments

Comments
 (0)