Skip to content

Commit

Permalink
Fixing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Dec 13, 2022
1 parent 78b9729 commit 1effeb9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ describe("animate", () => {
)
)
})
test("Correctly uses a keyframes animation if to is an array", async () => {
return new Promise<void>((resolve) =>
testAnimate(
{ keyframes: [0, 100], type: "spring" },
[0, 20, 40, 60, 80, 100],
resolve
)
)
})

test("Correctly stops an animation", async () => {
const output: number[] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ describe("animate prop as object", () => {
test("accepts custom transition prop", async () => {
const promise = new Promise((resolve) => {
const x = motionValue(0)
const onComplete = () => resolve(x.get())
const Component = () => (
<motion.div
animate={{ x: 20 }}
transition={{ x: { type: "tween", to: 50 } }}
transition={{
x: { type: "tween", from: 10, ease: () => 0.5 },
}}
onUpdate={() => resolve(x.get())}
style={{ x }}
onAnimationComplete={onComplete}
/>
)
const { rerender } = render(<Component />)
rerender(<Component />)
})
return expect(promise).resolves.toBe(50)
return expect(promise).resolves.toBe(15)
})
test("fires onAnimationStart when animation begins", async () => {
const promise = new Promise((resolve) => {
Expand Down Expand Up @@ -389,11 +390,10 @@ describe("animate prop as object", () => {
})
const Component = () => (
<motion.div
animate={{ x: 20 }}
animate={{ x: [0, 20] }}
transition={{
x: {
type: "tween",
to: 50,
duration: 0,
repeatDelay: 0.1,
repeat: 1,
Expand All @@ -406,7 +406,7 @@ describe("animate prop as object", () => {
const { rerender } = render(<Component />)
rerender(<Component />)
})
return expect(promise).resolves.toBe(50)
return expect(promise).resolves.toBe(20)
})
test("animates previously unseen properties", () => {
const Component = ({ animate }: any) => (
Expand Down
6 changes: 3 additions & 3 deletions packages/framer-motion/src/motion/__tests__/variant.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe("animate prop as variant", () => {
hidden: { background: "#00f" },
visible: {
background: "#f00",
transition: { to: "#555" },
transition: { from: "#555", ease: () => 0.5 },
},
}
const background = motionValue("#00f")
Expand All @@ -187,7 +187,7 @@ describe("animate prop as variant", () => {
animate="visible"
variants={variants}
transition={{ type: false }}
onAnimationComplete={onComplete}
onUpdate={onComplete}
style={{ background }}
/>
)
Expand All @@ -196,7 +196,7 @@ describe("animate prop as variant", () => {
rerender(<Component />)
})

return expect(promise).resolves.toBe("rgba(85, 85, 85, 1)")
return expect(promise).resolves.toBe("rgba(190, 60, 60, 1)")
})

test("respects orchestration props in transition prop", async () => {
Expand Down
1 change: 0 additions & 1 deletion packages/framer-motion/src/utils/delay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export function delay(callback: DelayedFunction, timeout: number) {
const checkElapsed = ({ timestamp }: FrameData) => {
const elapsed = timestamp - start

console.log(elapsed)
if (elapsed >= timeout) {
cancelSync.read(checkElapsed)
callback(elapsed - timeout)
Expand Down

0 comments on commit 1effeb9

Please sign in to comment.