Skip to content

Commit 7044009

Browse files
Merge branch 'next' into dependabot/npm_and_yarn/ini-1.3.7
2 parents fb04499 + 09e8834 commit 7044009

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

src/components/TileGallery/StatefulTileGallery.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const propTypes = {
4747
title: PropTypes.string.isRequired,
4848
description: PropTypes.string,
4949
moreInfoLink: PropTypes.string,
50+
onClick: PropTypes.func,
5051
icon: PropTypes.oneOfType([
5152
PropTypes.shape({
5253
width: PropTypes.string,
@@ -176,6 +177,7 @@ const StatefulTileGallery = ({
176177
mode={thumbnails ? 'grid' : 'list'}
177178
title={galleryItem.title}
178179
description={galleryItem.description}
180+
onClick={galleryItem.onClick}
179181
moreInfoLink={galleryItem.moreInfoLink}
180182
icon={galleryItem.icon}
181183
afterContent={galleryItem.afterContent}

src/components/TileGallery/TileGallery.test.jsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,22 @@ describe('TileGallery', () => {
146146
it('StatefulTileGallery', () => {
147147
const searchValue = 'description';
148148

149+
const onClick = jest.fn();
150+
151+
// replace storyboard action with jest.fn()
152+
const modifiedGalleryData = galleryData.map((gd) => ({
153+
...gd,
154+
galleryItems: gd.galleryItems.map((gi) => ({ ...gi, onClick })),
155+
}));
156+
149157
const wrapper = mount(
150158
<StatefulTileGallery
151159
title="Dashboard"
152160
hasSearch
153161
hasSwitcher
154162
hasButton
155163
buttonText="Create"
156-
galleryData={galleryData}
164+
galleryData={modifiedGalleryData}
157165
/>
158166
);
159167

@@ -173,6 +181,10 @@ describe('TileGallery', () => {
173181
'grid'
174182
);
175183

184+
// test tile onClick
185+
wrapper.find('.tile-gallery-item').first().simulate('click');
186+
expect(onClick).toHaveBeenCalledTimes(1);
187+
176188
// Change Tile Item mode
177189
wrapper.find('button.bx--content-switcher-btn').first().simulate('click');
178190
// console.log(`component::: ${noExtraWrapper.find('TileGallerySearch').debug()}`);

src/utils/__tests__/__snapshots__/publicAPI.test.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16917,6 +16917,9 @@ Map {
1691716917
"moreInfoLink": Object {
1691816918
"type": "string",
1691916919
},
16920+
"onClick": Object {
16921+
"type": "func",
16922+
},
1692016923
"thumbnail": Object {
1692116924
"type": "node",
1692216925
},

0 commit comments

Comments
 (0)