Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 4ccffd1

Browse files
committed
update test cases
1 parent fc99a7c commit 4ccffd1

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/__tests__/__snapshots__/index.snapshot.test.tsx.snap

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ exports[`Renders Horizontal Masonry with 2 columns 1`] = `
44
<ScrollView
55
contentContainerStyle={
66
Object {
7-
"flexDirection": "row",
7+
"flexDirection": "column",
88
}
99
}
10+
horizontal={true}
1011
>
1112
<View
1213
style={
1314
Array [
1415
Object {
15-
"flexDirection": "column",
16+
"flexDirection": "row",
1617
},
1718
null,
1819
null,
@@ -27,7 +28,7 @@ exports[`Renders Horizontal Masonry with 2 columns 1`] = `
2728
style={
2829
Array [
2930
Object {
30-
"flexDirection": "column",
31+
"flexDirection": "row",
3132
},
3233
null,
3334
null,
@@ -45,15 +46,16 @@ exports[`Renders Horizontal Masonry with 3 columns 1`] = `
4546
<ScrollView
4647
contentContainerStyle={
4748
Object {
48-
"flexDirection": "row",
49+
"flexDirection": "column",
4950
}
5051
}
52+
horizontal={true}
5153
>
5254
<View
5355
style={
5456
Array [
5557
Object {
56-
"flexDirection": "column",
58+
"flexDirection": "row",
5759
},
5860
null,
5961
null,
@@ -71,7 +73,7 @@ exports[`Renders Horizontal Masonry with 3 columns 1`] = `
7173
style={
7274
Array [
7375
Object {
74-
"flexDirection": "column",
76+
"flexDirection": "row",
7577
},
7678
null,
7779
null,

src/__tests__/index.snapshot.test.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { ReactElement } from "react";
22
import renderer from "react-test-renderer";
33
import RNMasonryScrollView from "../index";
44
import { Text } from "react-native";
@@ -15,9 +15,13 @@ const VMasonryComponentTwoColumns = () => {
1515
);
1616
};
1717

18-
it("Renders Vertical Masonry with 2 columns", () => {
19-
const tree = renderer.create(<VMasonryComponentTwoColumns />).toJSON();
18+
const testSnapShot = (Component: ReactElement) => {
19+
const tree = renderer.create(Component).toJSON();
2020
expect(tree).toMatchSnapshot();
21+
};
22+
23+
it("Renders Vertical Masonry with 2 columns", () => {
24+
testSnapShot(<VMasonryComponentTwoColumns />);
2125
});
2226

2327
const VMasonryComponentThreeColumns = () => {
@@ -33,26 +37,24 @@ const VMasonryComponentThreeColumns = () => {
3337
};
3438

3539
it("Renders Vertical Masonry with 3 columns", () => {
36-
const tree = renderer.create(<VMasonryComponentThreeColumns />).toJSON();
37-
expect(tree).toMatchSnapshot();
40+
testSnapShot(<VMasonryComponentThreeColumns />);
3841
});
3942

4043
const HMasonryComponentTwoColumns = () => {
4144
return (
42-
<RNMasonryScrollView>
45+
<RNMasonryScrollView horizontal={true}>
4346
{[<Text key={1}>{column1Text}</Text>, <Text key={2}>{column2Text}</Text>]}
4447
</RNMasonryScrollView>
4548
);
4649
};
4750

4851
it("Renders Horizontal Masonry with 2 columns", () => {
49-
const tree = renderer.create(<HMasonryComponentTwoColumns />).toJSON();
50-
expect(tree).toMatchSnapshot();
52+
testSnapShot(<HMasonryComponentTwoColumns />);
5153
});
5254

5355
const HMasonryComponentThreeColumns = () => {
5456
return (
55-
<RNMasonryScrollView>
57+
<RNMasonryScrollView horizontal={true}>
5658
{[
5759
<Text key={1}>{column1Text}</Text>,
5860
<Text key={2}>{column2Text}</Text>,
@@ -63,6 +65,5 @@ const HMasonryComponentThreeColumns = () => {
6365
};
6466

6567
it("Renders Horizontal Masonry with 3 columns", () => {
66-
const tree = renderer.create(<HMasonryComponentThreeColumns />).toJSON();
67-
expect(tree).toMatchSnapshot();
68+
testSnapShot(<HMasonryComponentThreeColumns />);
6869
});

0 commit comments

Comments
 (0)