Skip to content

Commit

Permalink
Adding failing tests for AnimatePresence (#2119)
Browse files Browse the repository at this point in the history
* Adding failing tests

* Updating lockfile
  • Loading branch information
mattgperry committed May 10, 2023
1 parent c06f44a commit 6a94425
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 5 deletions.
45 changes: 45 additions & 0 deletions dev/tests/animate-presence-remove.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { AnimatePresence, motion } from "framer-motion"
import * as React from "react"
import { useState } from "react"
import styled from "styled-components"

const Container = styled.section`
position: relative;
display: flex;
flex-direction: column;
padding: 100px;
div {
width: 100px;
height: 100px;
background-color: red;
}
`

const Box = ({ id }: { id: number }) => {
return (
<motion.div
id={`box-${id}`}
className="box"
transition={{ duration: 0.5 }}
exit={{ opacity: 0.5 }}
/>
)
}

export const App = () => {
const [range, setRange] = useState([0, 1, 2])

return (
<Container>
<button id="remove" onClick={() => setRange(range.slice(0, -1))}>
Remove
</button>
<AnimatePresence>
{range.map((i) => (
<Box key={i} id={i} />
))}
</AnimatePresence>
</Container>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe("AnimatePresence", () => {
it("Ensures all elements are removed", () => {
cy.visit("?test=animate-presence-remove")
.wait(50)
.get("#remove")
.trigger("click", 1, 1, { force: true })
.wait(100)
.trigger("click", 1, 1, { force: true })
.wait(700)
.get(".box")
.should((results) => {
expect(results.length).to.equal(1)
})
})
})
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7844,8 +7844,8 @@ __metadata:
cache-loader: ^1.2.5
convert-tsconfig-paths-to-webpack-aliases: ^0.9.2
fork-ts-checker-webpack-plugin: ^6.2.0
framer-motion: ^10.12.8
framer-motion-3d: ^10.12.8
framer-motion: ^10.12.9
framer-motion-3d: ^10.12.9
path-browserify: ^1.0.1
react: ^18.2.0
react-dom: ^18.2.0
Expand Down Expand Up @@ -7911,14 +7911,14 @@ __metadata:
languageName: unknown
linkType: soft

"framer-motion-3d@^10.12.8, framer-motion-3d@workspace:packages/framer-motion-3d":
"framer-motion-3d@^10.12.9, framer-motion-3d@workspace:packages/framer-motion-3d":
version: 0.0.0-use.local
resolution: "framer-motion-3d@workspace:packages/framer-motion-3d"
dependencies:
"@react-three/fiber": ^8.2.2
"@react-three/test-renderer": ^9.0.0
"@rollup/plugin-commonjs": ^22.0.1
framer-motion: ^10.12.8
framer-motion: ^10.12.9
react-merge-refs: ^2.0.1
peerDependencies:
"@react-three/fiber": ^8.2.2
Expand All @@ -7928,7 +7928,7 @@ __metadata:
languageName: unknown
linkType: soft

"framer-motion@^10.12.8, framer-motion@workspace:packages/framer-motion":
"framer-motion@^10.12.9, framer-motion@workspace:packages/framer-motion":
version: 0.0.0-use.local
resolution: "framer-motion@workspace:packages/framer-motion"
dependencies:
Expand Down

0 comments on commit 6a94425

Please sign in to comment.