Skip to content

Commit

Permalink
Removing test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed May 10, 2023
1 parent 46fbfd9 commit 6e68f17
Showing 1 changed file with 0 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,55 +111,6 @@ describe("AnimatePresence", () => {
expect(container.firstChild).toBeFalsy()
})

test("Animates out all components when unmounted in close succession", async () => {
const keys = [0, 1, 2]

const Component = ({ visibleKeys }: { visibleKeys: number[] }) => {
return (
<AnimatePresence>
{visibleKeys.map((key) => {
return (
<motion.div
key={key}
exit={{ opacity: 0 }}
transition={{ duration: 0.5 }}
/>
)
})}
</AnimatePresence>
)
}

const { container, rerender } = render(<Component visibleKeys={keys} />)

// Remove the last element from the array and wait briefly
await act(async () => {
rerender(<Component visibleKeys={[0, 1]} />)
await new Promise<void>((resolve) => {
setTimeout(() => {
resolve()
}, 100)
});
})

// Remove the second-to-last element from the array
await act(async () => {
rerender(<Component visibleKeys={[0]} />)
});

await act(async () => {
await new Promise<void>((resolve) => {
// Resolve after all animation is expected to have completed
setTimeout(() => {
resolve()
}, 1000)
})
})

// There should only be one element left
expect(container.childElementCount).toBe(1)
})

test("Allows nested exit animations", async () => {
const promise = new Promise((resolve) => {
const opacity = motionValue(0)
Expand Down

0 comments on commit 6e68f17

Please sign in to comment.