-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the web implementation for mocking (#1494)
- Loading branch information
1 parent
702d4d2
commit 81427a8
Showing
12 changed files
with
314 additions
and
163 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
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,7 @@ | ||
const globalSetup = async () => { | ||
const { LoadSkiaWeb } = require("../package/src/web/LoadSkiaWeb"); | ||
await LoadSkiaWeb(); | ||
}; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default globalSetup; |
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,33 @@ | ||
require("react-native-reanimated/lib/commonjs/reanimated2/jestUtils").setUpTests(); | ||
global.__reanimatedWorkletInit = () => {}; | ||
jest.mock("react-native-reanimated", () => { | ||
const Reanimated = require("react-native-reanimated/mock"); | ||
|
||
// The mock for `call` immediately calls the callback which is incorrect | ||
// So we override it with a no-op | ||
Reanimated.default.call = () => {}; | ||
Reanimated.Extrapolation = { | ||
CLAMP: "clamp", | ||
}; | ||
Reanimated.useEvent = () => {}; | ||
Reanimated.scrollTo = () => {}; | ||
return Reanimated; | ||
}); | ||
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing | ||
jest.mock("react-native/Libraries/Animated/NativeAnimatedHelper"); | ||
|
||
jest.mock("@shopify/react-native-skia", () => { | ||
return require("../package/src/mock").Mock(global.CanvasKit); | ||
}); | ||
|
||
const mockedNavigate = jest.fn(); | ||
|
||
jest.mock("@react-navigation/native", () => { | ||
const actualNav = jest.requireActual("@react-navigation/native"); | ||
return { | ||
...actualNav, | ||
useNavigation: () => ({ | ||
navigate: mockedNavigate, | ||
}), | ||
}; | ||
}); |
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
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
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,85 @@ | ||
import "react-native"; | ||
import React from "react"; | ||
// Test renderer must be required after react-native. | ||
import { cleanup, render } from "@testing-library/react-native"; | ||
|
||
import { Breathe } from "./Breathe"; | ||
import { Gooey } from "./Gooey"; | ||
import { Aurora } from "./Aurora"; | ||
import { Wallet } from "./Wallet"; | ||
import { Vertices } from "./Vertices"; | ||
import { Severance } from "./Severance"; | ||
import { PerformanceDrawingTest } from "./Performance"; | ||
import { GraphsScreen } from "./Graphs"; | ||
import { SimpleAnimation } from "./Animation/SimpleAnimation"; | ||
import { InterpolationWithEasing } from "./Animation/InterpolationWithEasing"; | ||
import { AnimationWithTouchHandler } from "./Animation/AnimationWithTouchHandler"; | ||
import { Neumorphism } from "./Neumorphism"; | ||
import { Matrix } from "./Matrix"; | ||
import { Hue } from "./Hue"; | ||
import { Glassmorphism } from "./Glassmorphism"; | ||
import { Filters } from "./Filters"; | ||
|
||
it("should render the Breathe example correctly", () => { | ||
render(<Breathe />); | ||
}); | ||
|
||
it("should render the Gooey example correctly", () => { | ||
render(<Gooey />); | ||
}); | ||
|
||
it("should render the Aurora example correctly", () => { | ||
render(<Aurora />); | ||
}); | ||
|
||
it("should render the Wallet example correctly", () => { | ||
render(<Wallet />); | ||
}); | ||
|
||
it("should render the Vertices example correctly", () => { | ||
render(<Vertices />); | ||
}); | ||
|
||
it("should render the Severance example correctly", () => { | ||
render(<Severance />); | ||
}); | ||
|
||
it("should render the Reanimated example correctly", () => { | ||
render( | ||
<> | ||
<SimpleAnimation /> | ||
<InterpolationWithEasing /> | ||
<AnimationWithTouchHandler /> | ||
</> | ||
); | ||
}); | ||
|
||
it("should render the Performance example correctly", () => { | ||
render(<PerformanceDrawingTest />); | ||
}); | ||
|
||
it("should render the Neumorphism example correctly", () => { | ||
render(<Neumorphism />); | ||
}); | ||
|
||
it("should render the Matrix example correctly", () => { | ||
render(<Matrix />); | ||
}); | ||
|
||
it("should render the Hue example correctly", () => { | ||
render(<Hue />); | ||
}); | ||
|
||
it("should render the GraphsScreen example correctly", () => { | ||
render(<GraphsScreen />); | ||
}); | ||
|
||
it("should render the Glassmorphism example correctly", () => { | ||
render(<Glassmorphism />); | ||
}); | ||
|
||
it("should render the Filter example correctly", () => { | ||
render(<Filters />); | ||
}); | ||
|
||
afterEach(cleanup); |
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
Oops, something went wrong.