Skip to content

Commit

Permalink
fix: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiqingchen committed Aug 22, 2024
1 parent f782762 commit ce3b461
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 246 deletions.
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@expo/webpack-config": "~19.0.1",
"@shopify/react-native-skia": "1.2.3",
"echarts": "^5.5.0",
"expo": "~51.0.26",
"expo": "~51.0.28",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.5",
Expand Down
50 changes: 26 additions & 24 deletions example/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,10 @@
mv "~2"
safe-json-stringify "~1"

"@expo/[email protected].28":
version "0.18.28"
resolved "https://registry.yarnpkg.com/@expo/cli/-/cli-0.18.28.tgz#eb49cbde4a3c9bdb24cc8f041dba425f93f3526e"
integrity sha512-fvbVPId6s6etindzP6Nzos/CS1NurMVy4JKozjebArHr63tBid5i/UY5Pp+4wTCAM20gB2SjRdwcwoL6HFC4Iw==
"@expo/[email protected].29":
version "0.18.29"
resolved "https://registry.yarnpkg.com/@expo/cli/-/cli-0.18.29.tgz#108682e28ccf3beab34938501d6dfc079683b82c"
integrity sha512-X810C48Ss+67RdZU39YEO1khNYo1RmjouRV+vVe0QhMoTe8R6OA3t+XYEdwaNbJ5p/DJN7szfHfNmX2glpC7xg==
dependencies:
"@babel/runtime" "^7.20.0"
"@expo/code-signing-certificates" "0.0.5"
Expand Down Expand Up @@ -2459,10 +2459,10 @@ babel-plugin-transform-flow-enums@^0.0.2:
dependencies:
"@babel/plugin-syntax-flow" "^7.12.1"

babel-preset-expo@~11.0.13:
version "11.0.13"
resolved "https://registry.yarnpkg.com/babel-preset-expo/-/babel-preset-expo-11.0.13.tgz#ccf349ca244a67a2ee57b6b57bd6468e9c892d71"
integrity sha512-5oUXyxnIVyDUhG4a306PpT2c9HhKx0tG4LXjpSIA/dERzwGvU8LUxDSD6yCohhRSsPZIoR7u2mnH0PypqFqYnQ==
babel-preset-expo@~11.0.14:
version "11.0.14"
resolved "https://registry.yarnpkg.com/babel-preset-expo/-/babel-preset-expo-11.0.14.tgz#ca0884e82d89e49cd216ad3497e3d7ad93657d51"
integrity sha512-4BVYR0Sc2sSNxYTiE/OLSnPiOp+weFNy8eV+hX3aD6YAIbBnw+VubKRWqJV/sOJauzOLz0SgYAYyFciYMqizRA==
dependencies:
"@babel/plugin-proposal-decorators" "^7.12.9"
"@babel/plugin-transform-export-namespace-from" "^7.22.11"
Expand Down Expand Up @@ -3880,21 +3880,23 @@ expo-keep-awake@~13.0.2:
resolved "https://registry.yarnpkg.com/expo-keep-awake/-/expo-keep-awake-13.0.2.tgz#5ef31311a339671eec9921b934fdd90ab9652b0e"
integrity sha512-kKiwkVg/bY0AJ5q1Pxnm/GvpeB6hbNJhcFsoOWDh2NlpibhCLaHL826KHUM+WsnJRbVRxJ+K9vbPRHEMvFpVyw==

[email protected].1:
version "1.11.1"
resolved "https://registry.yarnpkg.com/expo-modules-autolinking/-/expo-modules-autolinking-1.11.1.tgz#4a867f727d9dfde07de8dde14b333a3cbf82ce3c"
integrity sha512-2dy3lTz76adOl7QUvbreMCrXyzUiF8lygI7iFJLjgIQIVH+43KnFWE5zBumpPbkiaq0f0uaFpN9U0RGQbnKiMw==
[email protected].2:
version "1.11.2"
resolved "https://registry.yarnpkg.com/expo-modules-autolinking/-/expo-modules-autolinking-1.11.2.tgz#98245eb66f157bbfebebd2d576256ea7c683c605"
integrity sha512-fdcaNO8ucHA3yLNY52ZUENBcAG7KEx8QyMmnVNavO1JVBGRMZG8JyVcbrhYQDtVtpxkbai5YzwvLutINvbDZDQ==
dependencies:
chalk "^4.1.0"
commander "^7.2.0"
fast-glob "^3.2.5"
find-up "^5.0.0"
fs-extra "^9.1.0"
require-from-string "^2.0.2"
resolve-from "^5.0.0"

[email protected].20:
version "1.12.20"
resolved "https://registry.yarnpkg.com/expo-modules-core/-/expo-modules-core-1.12.20.tgz#072dea10791f32ea5d1d3b15a7d5fd1984173429"
integrity sha512-CCXjlgT8lDAufgt912P1W7TwD+KAylfIttc1Doh1a0hAfkdkUsDRmrgthnYrrxEo2ECVpbaB71Epp1bnZ1rRrA==
[email protected].21:
version "1.12.21"
resolved "https://registry.yarnpkg.com/expo-modules-core/-/expo-modules-core-1.12.21.tgz#8014fa549af3c1c00b14fd84a26ef921b39207fb"
integrity sha512-UQxRljqPcowS1+bECW9tnuVGfvWL18GAKPiKMnu9sZwJssAN9FU/JhED50DJzdzICLR0hL17FZAgV4rbMG3IWQ==
dependencies:
invariant "^2.2.4"

Expand All @@ -3908,24 +3910,24 @@ [email protected]:
commander "2.20.0"
update-check "1.5.3"

expo@~51.0.26:
version "51.0.26"
resolved "https://registry.yarnpkg.com/expo/-/expo-51.0.26.tgz#a19b891f8d1f1e7639dc375fa69a152ab6f4843a"
integrity sha512-7ThQa6CVbiVtk4GNw0E9CewSzXYOeHkcRTCGorBZVcjAu6SuxbdWEtl0RI01/VpRKV+6I+yy/BmGnCl7lFRILg==
expo@~51.0.28:
version "51.0.28"
resolved "https://registry.yarnpkg.com/expo/-/expo-51.0.28.tgz#d60cbe6803e29f0c09ba3681462f91e13bc849ef"
integrity sha512-R+0tSV0Zf5R+DxN4W3mLFlVvYVpiJ+dtYrMmBedIRw0A54we50QRM1jS0Gq2Bdzg2JtainSEApdQXUC6r9j/BA==
dependencies:
"@babel/runtime" "^7.20.0"
"@expo/cli" "0.18.28"
"@expo/cli" "0.18.29"
"@expo/config" "9.0.3"
"@expo/config-plugins" "8.0.8"
"@expo/metro-config" "0.18.11"
"@expo/vector-icons" "^14.0.0"
babel-preset-expo "~11.0.13"
babel-preset-expo "~11.0.14"
expo-asset "~10.0.10"
expo-file-system "~17.0.1"
expo-font "~12.0.9"
expo-keep-awake "~13.0.2"
expo-modules-autolinking "1.11.1"
expo-modules-core "1.12.20"
expo-modules-autolinking "1.11.2"
expo-modules-core "1.12.21"
fbemitter "^3.0.0"
whatwg-url-without-unicode "8.0.0-3"

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"react-native-svg": "15.2.0",
"react-test-renderer": "^18.3.1",
"release-it": "^17.2.1",
"sharp": "^0.33.3",
"sharp": "^0.33.5",
"typescript": "^5.0.4",
"zrender": "^5.5.0"
},
Expand Down
113 changes: 18 additions & 95 deletions src/__tests__/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SkiaChart Component does not render Canvas when svgString is not provided 1`] = `null`;

exports[`SkiaChart Component does not render GestureHandler when handleGesture is false 1`] = `
<View
style={
Expand All @@ -14,7 +12,7 @@ exports[`SkiaChart Component does not render GestureHandler when handleGesture i
/>
`;

exports[`SkiaChart Component renders Canvas when svgString is provided 1`] = `
exports[`SkiaChart Component renders GestureHandler when handleGesture is true and useRNGH is ture 1`] = `
<View
style={
{
Expand All @@ -25,18 +23,7 @@ exports[`SkiaChart Component renders Canvas when svgString is provided 1`] = `
testID="component"
>
<View
onMoveShouldSetResponder={[Function]}
onMoveShouldSetResponderCapture={[Function]}
onResponderEnd={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderReject={[Function]}
onResponderRelease={[Function]}
onResponderStart={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
onStartShouldSetResponderCapture={[Function]}
collapsable={false}
style={
{
"backgroundColor": "rgba(0,0,0,0)",
Expand All @@ -45,12 +32,12 @@ exports[`SkiaChart Component renders Canvas when svgString is provided 1`] = `
"width": "100%",
}
}
testID="pan-responder-handler"
testID="gesture-handler"
/>
</View>
`;

exports[`SkiaChart Component renders GestureHandler when handleGesture is true and useRNGH is ture 1`] = `
exports[`SkiaChart Component renders PanResponderHandler when handleGesture is true and useRNGH is false 1`] = `
<View
style={
{
Expand All @@ -61,7 +48,18 @@ exports[`SkiaChart Component renders GestureHandler when handleGesture is true a
testID="component"
>
<View
collapsable={false}
onMoveShouldSetResponder={[Function]}
onMoveShouldSetResponderCapture={[Function]}
onResponderEnd={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderReject={[Function]}
onResponderRelease={[Function]}
onResponderStart={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
onStartShouldSetResponderCapture={[Function]}
style={
{
"backgroundColor": "rgba(0,0,0,0)",
Expand All @@ -70,12 +68,12 @@ exports[`SkiaChart Component renders GestureHandler when handleGesture is true a
"width": "100%",
}
}
testID="gesture-handler"
testID="pan-responder-handler"
/>
</View>
`;

exports[`SkiaChart Component renders PanResponderHandler when handleGesture is true and useRNGH is false 1`] = `
exports[`SkiaChart Component renders correctly 1`] = `
<View
style={
{
Expand Down Expand Up @@ -111,10 +109,6 @@ exports[`SkiaChart Component renders PanResponderHandler when handleGesture is t
</View>
`;

exports[`SkiaChart Component renders correctly 1`] = `null`;

exports[`SvgChart Component does not render Canvas when svgString is not provided 1`] = `null`;

exports[`SvgChart Component does not render GestureHandler when handleGesture is false 1`] = `
<View
style={
Expand Down Expand Up @@ -163,77 +157,6 @@ exports[`SvgChart Component does not render GestureHandler when handleGesture is
</View>
`;

exports[`SvgChart Component renders Canvas when svgString is provided 1`] = `
<View
style={
{
"height": 100,
"width": 100,
}
}
testID="component"
>
<RNSVGSvgView
align="xMidYMid"
bbHeight={100}
bbWidth={100}
focusable={false}
height={100}
meetOrSlice={0}
minX={0}
minY={0}
style={
[
{
"backgroundColor": "transparent",
"borderWidth": 0,
},
{
"flex": 0,
"height": 100,
"width": 100,
},
]
}
vbHeight={100}
vbWidth={100}
width={100}
>
<RNSVGGroup
fill={
{
"payload": 4278190080,
"type": 0,
}
}
/>
</RNSVGSvgView>
<View
onMoveShouldSetResponder={[Function]}
onMoveShouldSetResponderCapture={[Function]}
onResponderEnd={[Function]}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderReject={[Function]}
onResponderRelease={[Function]}
onResponderStart={[Function]}
onResponderTerminate={[Function]}
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
onStartShouldSetResponderCapture={[Function]}
style={
{
"backgroundColor": "rgba(0,0,0,0)",
"height": "100%",
"position": "absolute",
"width": "100%",
}
}
testID="pan-responder-handler"
/>
</View>
`;

exports[`SvgChart Component renders GestureHandler when handleGesture is true and useRNGH is ture 1`] = `
<View
style={
Expand Down
14 changes: 0 additions & 14 deletions src/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,6 @@ Components.forEach((Component) => {
expect(toJSON()).toMatchSnapshot();
});

it('renders Canvas when svgString is provided', () => {
const { queryByTestId, toJSON } = render(
<Component svg={svg} node={node} />
);
expect(toJSON()).toMatchSnapshot();
expect(queryByTestId('component')).not.toBeNull();
});

it('does not render Canvas when svgString is not provided', () => {
const { queryByTestId, toJSON } = render(<Component />);
expect(toJSON()).toMatchSnapshot();
expect(queryByTestId('component')).toBeNull();
});

it('renders GestureHandler when handleGesture is true and useRNGH is ture', () => {
const { queryByTestId, toJSON } = render(
<Component svg={svg} node={node} useRNGH />
Expand Down
Loading

0 comments on commit ce3b461

Please sign in to comment.