Remove TestRenderer from dialog test

This commit is contained in:
Dave Parsons
2022-06-06 15:34:02 +02:00
committed by Ryan Gossiaux
parent 0314c69d20
commit 2332f365ef

View File

@@ -4,7 +4,6 @@ import ManagedDialog from "./_ManagedDialog.svelte";
import NestedTestComponent from "./_NestedTestComponent.svelte"; import NestedTestComponent from "./_NestedTestComponent.svelte";
import { suppressConsoleLogs } from "$lib/test-utils/suppress-console-logs"; import { suppressConsoleLogs } from "$lib/test-utils/suppress-console-logs";
import { render } from "@testing-library/svelte"; import { render } from "@testing-library/svelte";
import TestRenderer from "$lib/test-utils/TestRenderer.svelte";
import { import {
assertActiveElement, assertActiveElement,
assertDialog, assertDialog,
@@ -90,9 +89,9 @@ describe("Rendering", () => {
"should complain when an `open` prop is not a boolean", "should complain when an `open` prop is not a boolean",
suppressConsoleLogs(async () => { suppressConsoleLogs(async () => {
expect(() => expect(() =>
render(TestRenderer, { render(svelte`
allProps: [Dialog, { open: null, onClose: console.log, as: "div" }], <Dialog open={null} on:close={console.log} as="div" />
}) `)
).toThrowErrorMatchingInlineSnapshot( ).toThrowErrorMatchingInlineSnapshot(
`"You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: null"` `"You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: null"`
); );
@@ -359,17 +358,14 @@ describe('Composition', () => {
it( it(
'should be possible to open the Dialog via a Transition component', 'should be possible to open the Dialog via a Transition component',
suppressConsoleLogs(async () => { suppressConsoleLogs(async () => {
render( render(svelte`
TestRenderer, { <Transition show={true}>
allProps: [ <Dialog on:close={console.log}>
Transition, { show: true }, [ <DialogDescription>Description</DialogDescription>
Dialog, { onClose: console.log }, [ <TestTabSentinel />
[DialogDescription, {}, "Description"], </Dialog>
[TestTabSentinel] </Transition>
] `)
]
]
})
assertDialog({ state: DialogState.Visible }) assertDialog({ state: DialogState.Visible })
assertDialogDescription({ assertDialogDescription({
@@ -382,17 +378,14 @@ describe('Composition', () => {
it( it(
'should be possible to close the Dialog via a Transition component', 'should be possible to close the Dialog via a Transition component',
suppressConsoleLogs(async () => { suppressConsoleLogs(async () => {
render( render(svelte`
TestRenderer, { <Transition show={false}>
allProps: [ <Dialog on:close={console.log}>
Transition, { show: false }, [ <DialogDescription>Description</DialogDescription>
Dialog, { onClose: console.log }, [ <TestTabSentinel />
[DialogDescription, {}, "Description"], </Dialog>
[TestTabSentinel] </Transition>
] `)
]
]
})
assertDialog({ state: DialogState.InvisibleUnmounted }) assertDialog({ state: DialogState.InvisibleUnmounted })
}) })
@@ -404,15 +397,12 @@ describe('Keyboard interactions', () => {
it( it(
'should be possible to close the dialog with Escape', 'should be possible to close the dialog with Escape',
async () => { async () => {
render( render(svelte`
TestRenderer, { <ManagedDialog buttonText="Trigger" buttonProps={{ id: "trigger" }}>
allProps: [ Contents
[ManagedDialog, { buttonText: "Trigger", buttonProps: { id: "trigger" } }, [ <TestTabSentinel />
"Contents", </ManagedDialog>
[TestTabSentinel], `)
]],
]
})
assertDialog({ state: DialogState.InvisibleUnmounted }) assertDialog({ state: DialogState.InvisibleUnmounted })
@@ -498,16 +488,13 @@ describe('Mouse interactions', () => {
it( it(
'should be possible to close a Dialog using a click on the DialogOverlay', 'should be possible to close a Dialog using a click on the DialogOverlay',
suppressConsoleLogs(async () => { suppressConsoleLogs(async () => {
render( render(svelte`
TestRenderer, { <ManagedDialog buttonText="Trigger" buttonProps={{ id: "trigger" }}>
allProps: [ <DialogOverlay />
[ManagedDialog, { buttonText: "Trigger", buttonProps: { id: "trigger" } }, [ Contents
[DialogOverlay], <TestTabSentinel />
"Contents", </ManagedDialog>
[TestTabSentinel], `)
]],
]
})
// Open dialog // Open dialog
await click(document.getElementById('trigger')) await click(document.getElementById('trigger'))
@@ -553,15 +540,12 @@ describe('Mouse interactions', () => {
it( it(
'should be possible to close the dialog, and re-focus the button when we click outside on the body element', 'should be possible to close the dialog, and re-focus the button when we click outside on the body element',
suppressConsoleLogs(async () => { suppressConsoleLogs(async () => {
render( render(svelte`
TestRenderer, { <ManagedDialog buttonText="Trigger" buttonProps={{ id: "trigger" }}>
allProps: [ Contents
[ManagedDialog, { buttonText: "Trigger", buttonProps: { id: "trigger" } }, [ <TestTabSentinel />
"Contents", </ManagedDialog>
[TestTabSentinel], `)
]],
]
})
// Open dialog // Open dialog
await click(getByText('Trigger')) await click(getByText('Trigger'))