-
-
Notifications
You must be signed in to change notification settings - Fork 893
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding failing tests for
AnimatePresence
(#2119)
* Adding failing tests * Updating lockfile
- Loading branch information
1 parent
c06f44a
commit 6a94425
Showing
3 changed files
with
65 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/framer-motion/cypress/integration/animate-presence-remove.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters