Skip to content

Commit

Permalink
WIP: tests and changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanlegg committed Apr 26, 2024
1 parent 20e808a commit f684a45
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/sweet-masks-walk.md
@@ -0,0 +1,5 @@
---
'@shopify/polaris': patch
---

Add support for hiding selectable checkbox on a per `IndexTable.Row` basis via `hideSelectable` prop`
Expand Up @@ -14,6 +14,7 @@ import {Link} from '../../../../Link';
import {Checkbox as PolarisCheckbox} from '../../../../Checkbox';
import styles from '../../../IndexTable.module.css';
import type {Range} from '../../../../../utilities/index-provider';
import {Cell} from '../../Cell';

const defaultEvent = {
preventDefault: noop,
Expand Down Expand Up @@ -78,6 +79,29 @@ describe('<Row />', () => {
expect(row).not.toContainReactComponent(Checkbox);
});

it('renders checkboxes when hideSelectable is false and selectable set to true in IndexTable', () => {
const row = mountWithTable(
<Row {...defaultProps} hideSelectable={false}>
<th>Child</th>
</Row>,
{indexTableProps: {selectable: true}},
);

expect(row).toContainReactComponent(Checkbox);
});

it('does not render checkboxes when hideSelectable is true and selectable set to true in IndexTable', () => {
const row = mountWithTable(
<Row {...defaultProps} hideSelectable>
<th>Child</th>
</Row>,
{indexTableProps: {selectable: true}},
);

expect(row).not.toContainReactComponent(Checkbox);
expect(row).toContainReactComponent(Cell, {children: null});
});

it('renders a RowHoveredContext provider', () => {
const row = mountWithTable(
<Row id="id" selected position={1}>
Expand Down

0 comments on commit f684a45

Please sign in to comment.