From 3bd55cd34e8c85a530d8dcd1da15485395bff116 Mon Sep 17 00:00:00 2001 From: Andrei Zhaleznichenka Date: Fri, 15 Sep 2023 14:17:49 +0200 Subject: [PATCH] add resizer.click test cov --- .../__tests__/resizable-columns.test.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/table/__tests__/resizable-columns.test.tsx b/src/table/__tests__/resizable-columns.test.tsx index 38663a0968..ac3885b296 100644 --- a/src/table/__tests__/resizable-columns.test.tsx +++ b/src/table/__tests__/resizable-columns.test.tsx @@ -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( onChange(event.detail)} />); const columnResizerWrapper = wrapper.findColumnResizer(1)!; @@ -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(
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(
onChange(event.detail)} />); const columnResizerWrapper = wrapper.findColumnResizer(1)!; @@ -364,6 +378,8 @@ describe('resize with keyboard', () => { expect(onChange).toHaveBeenCalledTimes(0); }); + + // TODO: add tests for aria-roledescription content }); describe('column header content', () => {