Skip to content

Commit

Permalink
Fixing failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Sep 24, 2024
1 parent 3023523 commit 8500196
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { motionValue } from "../../../value"
import { ResolvedValues } from "../../../render/types"
import { nextFrame } from "../../../gestures/__tests__/utils"
import { waitFor } from "@testing-library/dom"

describe("AnimatePresence", () => {
test("Allows initial animation if no `initial` prop defined", async () => {
Expand Down Expand Up @@ -445,7 +446,7 @@ describe("AnimatePresence", () => {
})

test("Fast animations with wait render the child content correctly (strict mode disabled)", async () => {
const promise = new Promise<boolean>((resolve) => {
await new Promise<boolean>((resolve) => {
const Component = ({ i }: { i: number }) => {
return (
<AnimatePresence mode="wait">
Expand All @@ -470,13 +471,16 @@ describe("AnimatePresence", () => {
setTimeout(() => {
rerender(<Component i={2} />)
// wait for the exit animation to check the DOM again
setTimeout(() => {
resolve(getByTestId("2").textContent === "2")
}, 150)
async function checkElement() {
await waitFor(() =>
expect(getByTestId("2").textContent === "2")
)
resolve(true)
}

checkElement()
}, 200)
})

return await expect(promise).resolves.toBeTruthy()
})

test("Elements exit in sequence during fast renders", async () => {
Expand Down

0 comments on commit 8500196

Please sign in to comment.