forked from motiondivision/motion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix MotionConfig does not propagate changes to transition
- Loading branch information
1 parent
8ebef8c
commit 97c714a
Showing
3 changed files
with
38 additions
and
9 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
30 changes: 30 additions & 0 deletions
30
src/components/MotionConfig/__tests__/MotionConfig.test.tsx
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,30 @@ | ||
import * as React from "react" | ||
import { render } from "@testing-library/react" | ||
import { MotionConfig } from ".." | ||
import { MotionConfigContext } from "../../../context/MotionConfigContext" | ||
|
||
const consumerId = "consumer" | ||
|
||
const Consumer = () => { | ||
const value = React.useContext(MotionConfigContext) | ||
return <div data-testid={consumerId}>{value.transition!.type}</div> | ||
} | ||
|
||
const App = ({ type }: { type: string }) => ( | ||
<MotionConfig transition={{ type }}> | ||
<Consumer /> | ||
</MotionConfig> | ||
) | ||
|
||
it("Passes down transition", () => { | ||
const { getByTestId } = render(<App type="spring" />) | ||
|
||
expect(getByTestId(consumerId).textContent).toBe("spring") | ||
}) | ||
|
||
it("Passes down transition changes", () => { | ||
const { getByTestId, rerender } = render(<App type="spring" />) | ||
rerender(<App type="tween" />) | ||
|
||
expect(getByTestId(consumerId).textContent).toBe("tween") | ||
}) |
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