Skip to content

Commit 900757c

Browse files
authored
fix(content-explorer): Add default dimension to ItemListIcon (#4052)
1 parent 6981964 commit 900757c

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

src/elements/common/item/IconCell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import messages from '../messages';
1313
import './IconCell.scss';
1414

1515
export interface IconCellProps {
16-
dimension?: number;
16+
dimension: number;
1717
rowData: BoxItem;
1818
}
1919

src/features/content-explorer/item-list/ItemListIcon.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ import PropTypes from 'prop-types';
44
import { ItemTypePropType, ItemArchiveTypePropType } from '../prop-types';
55
import IconCell from '../../../elements/common/item/IconCell';
66

7-
const ItemListIcon = ({ archiveType, extension, type, hasCollaborations = false, isExternallyOwned = false }) => {
7+
const ItemListIcon = ({
8+
archiveType,
9+
extension,
10+
type,
11+
hasCollaborations = false,
12+
isExternallyOwned = false,
13+
dimension = 32,
14+
}) => {
815
const rowData = {
916
type,
1017
extension,
1118
has_collaborations: hasCollaborations,
1219
is_externally_owned: isExternallyOwned,
1320
archive_type: archiveType,
1421
};
15-
return <IconCell rowData={rowData} />;
22+
return <IconCell rowData={rowData} dimension={dimension} />;
1623
};
1724

1825
ItemListIcon.propTypes = {

src/features/content-explorer/item-list/__tests__/ItemListIcon.test.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ import { render, screen } from '../../../../test-utils/testing-library';
66
describe('features/content-explorer/item-list/ItemListIcon', () => {
77
const renderComponent = props => render(<ItemListIcon {...props} />);
88

9+
const expectIconWithDefaultSize = icon => {
10+
expect(icon).toBeVisible();
11+
expect(icon).toHaveAttribute('width', '32');
12+
expect(icon).toHaveAttribute('height', '32');
13+
};
14+
915
describe('render()', () => {
1016
test('should render default file icon', () => {
1117
renderComponent({});
1218

13-
expect(screen.getByLabelText('File')).toBeInTheDocument();
19+
const fileIcon = screen.getByLabelText('File');
20+
expectIconWithDefaultSize(fileIcon);
1421
});
1522

1623
test('should render archive icon', () => {
@@ -22,7 +29,8 @@ describe('features/content-explorer/item-list/ItemListIcon', () => {
2229
};
2330
renderComponent(rowData);
2431

25-
expect(screen.getByLabelText('Archive')).toBeVisible();
32+
const archiveIcon = screen.getByLabelText('Archive');
33+
expectIconWithDefaultSize(archiveIcon);
2634
});
2735

2836
test('should render archived folder icon', () => {
@@ -34,7 +42,8 @@ describe('features/content-explorer/item-list/ItemListIcon', () => {
3442
};
3543
renderComponent(rowData);
3644

37-
expect(screen.getByLabelText('Archived Folder')).toBeVisible();
45+
const archivedFolderIcon = screen.getByLabelText('Archived Folder');
46+
expectIconWithDefaultSize(archivedFolderIcon);
3847
});
3948

4049
test.each([
@@ -68,22 +77,25 @@ describe('features/content-explorer/item-list/ItemListIcon', () => {
6877
])('should render $label folder icon', ({ rowData, label }) => {
6978
renderComponent(rowData);
7079

71-
expect(screen.getByLabelText(label)).toBeInTheDocument();
80+
const folderIcon = screen.getByLabelText(label);
81+
expectIconWithDefaultSize(folderIcon);
7282
});
7383

7484
test('should render correct file icon', () => {
7585
const extension = 'boxnote';
7686
const rowData = { type: 'file', extension };
7787
renderComponent(rowData);
7888

79-
expect(screen.getByLabelText('BOXNOTE File')).toBeInTheDocument();
89+
const fileIcon = screen.getByLabelText('BOXNOTE File');
90+
expectIconWithDefaultSize(fileIcon);
8091
});
8192

8293
test('should render correct bookmark icon', () => {
8394
const rowData = { type: 'web_link' };
8495
renderComponent(rowData);
8596

86-
expect(screen.getByLabelText('Bookmark')).toBeInTheDocument();
97+
const bookmarkIcon = screen.getByLabelText('Bookmark');
98+
expectIconWithDefaultSize(bookmarkIcon);
8799
});
88100
});
89101
});

0 commit comments

Comments
 (0)