Skip to content

Commit

Permalink
add resizer.click test cov
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-kot committed Sep 15, 2023
1 parent a8b32fb commit 3bd55cd
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/table/__tests__/resizable-columns.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ describe('resize with keyboard', () => {
expect(onChange).toHaveBeenCalledTimes(0);
});

test.each([KeyCode.space, KeyCode.enter])('activates and commits resize with [%s] key code', keyCode => {
test.each([KeyCode.space, KeyCode.enter])('activates and commits keyboard resize with keyCode="%s"', keyCode => {
const onChange = jest.fn();
const { wrapper } = renderTable(<Table {...defaultProps} onColumnWidthsChange={event => onChange(event.detail)} />);
const columnResizerWrapper = wrapper.findColumnResizer(1)!;
Expand All @@ -336,7 +336,21 @@ describe('resize with keyboard', () => {
expect(onChange).toHaveBeenCalledWith({ widths: [140, 300] });
});

test.each([KeyCode.escape])('discards resize with [%s] key code', keyCode => {
test('activates keyboard resize with click', () => {
const onChange = jest.fn();
const { wrapper } = renderTable(<Table {...defaultProps} onColumnWidthsChange={event => onChange(event.detail)} />);
const columnResizerWrapper = wrapper.findColumnResizer(1)!;

columnResizerWrapper.focus();
columnResizerWrapper.click();
columnResizerWrapper.keydown(KeyCode.right);
columnResizerWrapper.keydown(KeyCode.enter);

expect(onChange).toHaveBeenCalledTimes(1);
expect(onChange).toHaveBeenCalledWith({ widths: [160, 300] });
});

test.each([KeyCode.escape])('discards resize with escape', keyCode => {
const onChange = jest.fn();
const { wrapper } = renderTable(<Table {...defaultProps} onColumnWidthsChange={event => onChange(event.detail)} />);
const columnResizerWrapper = wrapper.findColumnResizer(1)!;
Expand Down Expand Up @@ -364,6 +378,8 @@ describe('resize with keyboard', () => {

expect(onChange).toHaveBeenCalledTimes(0);
});

// TODO: add tests for aria-roledescription content
});

describe('column header content', () => {
Expand Down

0 comments on commit 3bd55cd

Please sign in to comment.