1- import React from "react" ;
1+ import React , { ReactElement } from "react" ;
22import renderer from "react-test-renderer" ;
33import RNMasonryScrollView from "../index" ;
44import { 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
2327const VMasonryComponentThreeColumns = ( ) => {
@@ -33,26 +37,24 @@ const VMasonryComponentThreeColumns = () => {
3337} ;
3438
3539it ( "Renders Vertical Masonry with 3 columns" , ( ) => {
36- const tree = renderer . create ( < VMasonryComponentThreeColumns /> ) . toJSON ( ) ;
37- expect ( tree ) . toMatchSnapshot ( ) ;
40+ testSnapShot ( < VMasonryComponentThreeColumns /> ) ;
3841} ) ;
3942
4043const 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
4851it ( "Renders Horizontal Masonry with 2 columns" , ( ) => {
49- const tree = renderer . create ( < HMasonryComponentTwoColumns /> ) . toJSON ( ) ;
50- expect ( tree ) . toMatchSnapshot ( ) ;
52+ testSnapShot ( < HMasonryComponentTwoColumns /> ) ;
5153} ) ;
5254
5355const 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
6567it ( "Renders Horizontal Masonry with 3 columns" , ( ) => {
66- const tree = renderer . create ( < HMasonryComponentThreeColumns /> ) . toJSON ( ) ;
67- expect ( tree ) . toMatchSnapshot ( ) ;
68+ testSnapShot ( < HMasonryComponentThreeColumns /> ) ;
6869} ) ;
0 commit comments