1- import { listAction , listExp , setupIntersectionObserverStub } from "@mendix/widget-plugin-test-utils" ;
1+ import { listAction , listExpression , setupIntersectionObserverStub } from "@mendix/widget-plugin-test-utils" ;
22import "@testing-library/jest-dom" ;
33import { render , waitFor } from "@testing-library/react" ;
44import { ObjectItem } from "mendix" ;
5+ import { createElement } from "react" ;
56import { ItemHelperBuilder } from "../../utils/builders/ItemHelperBuilder" ;
67import { mockItemHelperWithAction , mockProps , setup , withGalleryContext } from "../../utils/test-utils" ;
78import { Gallery } from "../Gallery" ;
89
10+ jest . mock ( "@mendix/widget-plugin-component-kit/RefreshIndicator" , ( ) => ( {
11+ RefreshIndicator : ( _props : any ) => createElement ( "div" , { "data-testid" : "refresh-indicator" } )
12+ } ) ) ;
13+
914describe ( "Gallery" , ( ) => {
1015 beforeAll ( ( ) => {
1116 setupIntersectionObserverStub ( ) ;
@@ -24,6 +29,20 @@ describe("Gallery", () => {
2429
2530 expect ( asFragment ( ) ) . toMatchSnapshot ( ) ;
2631 } ) ;
32+
33+ it ( "renders RefreshIndicator when `showRefreshIndicator` is true" , ( ) => {
34+ const base = mockProps ( ) ;
35+ const props = { ...base , showRefreshIndicator : true } ;
36+ const { getByTestId } = render ( withGalleryContext ( < Gallery { ...props } /> ) ) ;
37+ expect ( getByTestId ( "refresh-indicator" ) ) . toBeInTheDocument ( ) ;
38+ } ) ;
39+
40+ it ( "does not render RefreshIndicator when `showRefreshIndicator` is false" , ( ) => {
41+ const base = mockProps ( ) ;
42+ const props = { ...base , showRefreshIndicator : false } ;
43+ const { queryByTestId } = render ( withGalleryContext ( < Gallery { ...props } /> ) ) ;
44+ expect ( queryByTestId ( "refresh-indicator" ) ) . toBeNull ( ) ;
45+ } ) ;
2746 } ) ;
2847
2948 describe ( "with on click action" , ( ) => {
@@ -84,7 +103,9 @@ describe("Gallery", () => {
84103 withGalleryContext (
85104 < Gallery
86105 { ...mockProps ( ) }
87- itemHelper = { ItemHelperBuilder . sample ( b => b . withItemClass ( listExp ( ( ) => "custom-class" ) ) ) }
106+ itemHelper = { ItemHelperBuilder . sample ( b =>
107+ b . withItemClass ( listExpression ( ( ) => "custom-class" ) )
108+ ) }
88109 />
89110 )
90111 ) ;
0 commit comments