1+ /* eslint-disable jest/no-disabled-tests */
12/**
23 * @jest -environment jsdom
34 */
@@ -17,7 +18,17 @@ const itemWrapperFunction =
1718const defaultProps : GalleryProps < ObjectItem > = {
1819 hasMoreItems : true ,
1920 itemRenderer : itemWrapperFunction ( { } ) ,
20- items : [ { id : "11" as GUID } , { id : "22" as GUID } , { id : "33" as GUID } ] ,
21+ items : [
22+ { id : "11" as GUID } ,
23+ { id : "22" as GUID } ,
24+ { id : "33" as GUID } ,
25+ { id : "44" as GUID } ,
26+ { id : "55" as GUID } ,
27+ { id : "66" as GUID } ,
28+ { id : "77" as GUID } ,
29+ { id : "88" as GUID } ,
30+ { id : "99" as GUID }
31+ ] ,
2132 loadMoreItems : jest . fn ( ) ,
2233 name : "gallery-test" ,
2334 pagination : "virtualScrolling" ,
@@ -127,42 +138,14 @@ describe("Gallery", () => {
127138 it ( "triggers load more items events on end reached" , ( ) => {
128139 const gallery = render ( < Gallery { ...defaultProps } /> ) ;
129140 const galleryList = gallery . getByTestId ( "gallery-test-list" ) ;
130- fireEvent . scroll ( galleryList , {
131- nativeEvent : {
132- contentOffset : {
133- y : 500
134- } ,
135- contentSize : {
136- height : 500 ,
137- width : 100
138- } ,
139- layoutMeasurement : {
140- height : 100 ,
141- width : 100
142- }
143- }
144- } ) ;
141+ fireEvent ( galleryList , "onEndReached" ) ;
145142 expect ( defaultProps . loadMoreItems ) . toBeCalledTimes ( 1 ) ;
146143 } ) ;
147144
148145 it ( "it shouldn't triggers the load more items event when item list empty" , ( ) => {
149146 const gallery = render ( < Gallery { ...defaultProps } items = { [ ] } hasMoreItems = { false } /> ) ;
150147 const galleryList = gallery . getByTestId ( "gallery-test-list" ) ;
151- fireEvent . scroll ( galleryList , {
152- nativeEvent : {
153- contentOffset : {
154- y : 500
155- } ,
156- contentSize : {
157- height : 500 ,
158- width : 100
159- } ,
160- layoutMeasurement : {
161- height : 100 ,
162- width : 100
163- }
164- }
165- } ) ;
148+ fireEvent ( galleryList , "onEndReached" ) ;
166149 expect ( defaultProps . loadMoreItems ) . not . toBeCalled ( ) ;
167150 } ) ;
168151
0 commit comments