Skip to content

Commit

Permalink
Adding test for unit conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Apr 11, 2024
1 parent 6f4813f commit 166534a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
17 changes: 17 additions & 0 deletions dev/tests/unit-conversion-vh.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from "react"
import { motion } from "framer-motion"

/**
* An example of animating between different value types
*/

export const App = () => {
return (
<motion.div
animate={{ height: "50vh", width: 100 }}
transition={{ duration: 5, ease: () => 0.5 }}
style={{ width: "50vw", height: 100, background: "#ffaa00" }}
id="box"
/>
)
}
12 changes: 12 additions & 0 deletions packages/framer-motion/cypress/integration/unit-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,16 @@ describe("Unit conversion", () => {
expect(left).to.equal(150)
})
})

it("Animate width and height to/from vh units", () => {
cy.viewport(400, 400)
.visit("?test=unit-conversion-vh")
.wait(100)
.get("#box")
.should(([$box]: any) => {
const { width, height } = $box.getBoundingClientRect()
expect(width).to.equal(150)
expect(height).to.equal(150)
})
})
})

0 comments on commit 166534a

Please sign in to comment.