Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(react): update InlineCheckbox to FC #10363

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('DataTable.TableSelectAll', () => {
</TableHead>
</Table>
);
wrapper.find('InlineCheckbox input').simulate('click');
wrapper.find('input').simulate('click');
expect(mockProps.onSelect).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('DataTable.TableSelectRow', () => {
</TableHead>
</Table>
);
wrapper.find('InlineCheckbox input').simulate('click');
wrapper.find('input').simulate('click');
expect(mockProps.onSelect).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -975,32 +975,21 @@ exports[`DataTable selection should have select-all default to un-checked if no
name="select-all"
onClick={[Function]}
>
<InlineCheckbox
ariaLabel="Select all rows"
<input
checked={false}
className="bx--checkbox"
id="data-table-7__select-all"
indeterminate={false}
innerRef={null}
name="select-all"
onChange={[Function]}
onClick={[Function]}
>
<input
checked={false}
className="bx--checkbox"
id="data-table-7__select-all"
name="select-all"
onChange={[Function]}
onClick={[Function]}
type="checkbox"
/>
<label
aria-label="Select all rows"
className="bx--checkbox-label"
htmlFor="data-table-7__select-all"
onClick={[Function]}
/>
</InlineCheckbox>
type="checkbox"
/>
<label
aria-label="Select all rows"
className="bx--checkbox-label"
htmlFor="data-table-7__select-all"
onClick={[Function]}
/>
</ForwardRef(InlineCheckbox)>
</th>
</TableSelectAll>
Expand Down Expand Up @@ -1382,32 +1371,21 @@ exports[`DataTable selection should render 1`] = `
name="select-all"
onClick={[Function]}
>
<InlineCheckbox
ariaLabel="Select all rows"
<input
checked={false}
className="bx--checkbox"
id="data-table-6__select-all"
indeterminate={false}
innerRef={null}
name="select-all"
onChange={[Function]}
onClick={[Function]}
>
<input
checked={false}
className="bx--checkbox"
id="data-table-6__select-all"
name="select-all"
onChange={[Function]}
onClick={[Function]}
type="checkbox"
/>
<label
aria-label="Select all rows"
className="bx--checkbox-label"
htmlFor="data-table-6__select-all"
onClick={[Function]}
/>
</InlineCheckbox>
type="checkbox"
/>
<label
aria-label="Select all rows"
className="bx--checkbox-label"
htmlFor="data-table-6__select-all"
onClick={[Function]}
/>
</ForwardRef(InlineCheckbox)>
</th>
</TableSelectAll>
Expand Down Expand Up @@ -1483,33 +1461,22 @@ exports[`DataTable selection should render 1`] = `
name="select-row-b"
onClick={[Function]}
>
<InlineCheckbox
ariaLabel="Select row"
<input
checked={false}
className="bx--checkbox"
disabled={false}
id="data-table-6__select-row-b"
innerRef={null}
name="select-row-b"
onChange={[Function]}
onClick={[Function]}
>
<input
checked={false}
className="bx--checkbox"
disabled={false}
id="data-table-6__select-row-b"
name="select-row-b"
onChange={[Function]}
onClick={[Function]}
type="checkbox"
/>
<label
aria-label="Select row"
className="bx--checkbox-label"
htmlFor="data-table-6__select-row-b"
onClick={[Function]}
/>
</InlineCheckbox>
type="checkbox"
/>
<label
aria-label="Select row"
className="bx--checkbox-label"
htmlFor="data-table-6__select-row-b"
onClick={[Function]}
/>
</ForwardRef(InlineCheckbox)>
</td>
</TableSelectRow>
Expand Down Expand Up @@ -1553,33 +1520,22 @@ exports[`DataTable selection should render 1`] = `
name="select-row-a"
onClick={[Function]}
>
<InlineCheckbox
ariaLabel="Select row"
<input
checked={false}
className="bx--checkbox"
disabled={false}
id="data-table-6__select-row-a"
innerRef={null}
name="select-row-a"
onChange={[Function]}
onClick={[Function]}
>
<input
checked={false}
className="bx--checkbox"
disabled={false}
id="data-table-6__select-row-a"
name="select-row-a"
onChange={[Function]}
onClick={[Function]}
type="checkbox"
/>
<label
aria-label="Select row"
className="bx--checkbox-label"
htmlFor="data-table-6__select-row-a"
onClick={[Function]}
/>
</InlineCheckbox>
type="checkbox"
/>
<label
aria-label="Select row"
className="bx--checkbox-label"
htmlFor="data-table-6__select-row-a"
onClick={[Function]}
/>
</ForwardRef(InlineCheckbox)>
</td>
</TableSelectRow>
Expand Down Expand Up @@ -1623,33 +1579,22 @@ exports[`DataTable selection should render 1`] = `
name="select-row-c"
onClick={[Function]}
>
<InlineCheckbox
ariaLabel="Select row"
<input
checked={false}
className="bx--checkbox"
disabled={false}
id="data-table-6__select-row-c"
innerRef={null}
name="select-row-c"
onChange={[Function]}
onClick={[Function]}
>
<input
checked={false}
className="bx--checkbox"
disabled={false}
id="data-table-6__select-row-c"
name="select-row-c"
onChange={[Function]}
onClick={[Function]}
type="checkbox"
/>
<label
aria-label="Select row"
className="bx--checkbox-label"
htmlFor="data-table-6__select-row-c"
onClick={[Function]}
/>
</InlineCheckbox>
type="checkbox"
/>
<label
aria-label="Select row"
className="bx--checkbox-label"
htmlFor="data-table-6__select-row-c"
onClick={[Function]}
/>
</ForwardRef(InlineCheckbox)>
</td>
</TableSelectRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,21 @@ exports[`DataTable.TableSelectAll should render 1`] = `
name="select-all"
onClick={[MockFunction]}
>
<InlineCheckbox
ariaLabel="Select all rows in the table"
<input
checked={false}
className="bx--checkbox"
id="id"
innerRef={null}
name="select-all"
onChange={[Function]}
onClick={[MockFunction]}
>
<input
checked={false}
className="bx--checkbox"
id="id"
name="select-all"
onChange={[Function]}
onClick={[MockFunction]}
type="checkbox"
/>
<label
aria-label="Select all rows in the table"
className="bx--checkbox-label"
htmlFor="id"
onClick={[Function]}
/>
</InlineCheckbox>
type="checkbox"
/>
<label
aria-label="Select all rows in the table"
className="bx--checkbox-label"
htmlFor="id"
onClick={[Function]}
/>
</ForwardRef(InlineCheckbox)>
</th>
</TableSelectAll>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,21 @@ exports[`DataTable.TableSelectRow should render 1`] = `
name="select-all"
onClick={[MockFunction]}
>
<InlineCheckbox
ariaLabel="Aria label"
<input
checked={false}
className="bx--checkbox"
id="id"
innerRef={null}
name="select-all"
onChange={[Function]}
onClick={[MockFunction]}
>
<input
checked={false}
className="bx--checkbox"
id="id"
name="select-all"
onChange={[Function]}
onClick={[MockFunction]}
type="checkbox"
/>
<label
aria-label="Aria label"
className="bx--checkbox-label"
htmlFor="id"
onClick={[Function]}
/>
</InlineCheckbox>
type="checkbox"
/>
<label
aria-label="Aria label"
className="bx--checkbox-label"
htmlFor="id"
onClick={[Function]}
/>
</ForwardRef(InlineCheckbox)>
</td>
</TableSelectRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import userEvent from '@testing-library/user-event';

describe('InlineCheckbox', () => {
it('should render', () => {
render(<InlineCheckbox />);
render(
<InlineCheckbox ariaLabel="test-label" id="test-id" name="test-name" />
);
expect(screen.getByRole('checkbox')).toBeInTheDocument();
});

Expand All @@ -21,7 +23,7 @@ describe('InlineCheckbox', () => {
render(
/* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */
<div onClick={onClick}>
<InlineCheckbox />
<InlineCheckbox ariaLabel="test-label" id="test-id" name="test-name" />
</div>
);
userEvent.click(screen.getByRole('checkbox'));
Expand Down
Loading