From 2734915bd3cc4c3791248514ae0638d8ab254475 Mon Sep 17 00:00:00 2001 From: Gordon Ko Date: Mon, 9 Oct 2023 18:28:36 -0400 Subject: [PATCH] add test --- test/column/resizable.test.tsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/column/resizable.test.tsx b/test/column/resizable.test.tsx index 0ef72ea898..1bf885f48f 100644 --- a/test/column/resizable.test.tsx +++ b/test/column/resizable.test.tsx @@ -1,4 +1,5 @@ import { fireEvent } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import type { Column } from '../../src'; import { resizeHandleClassname } from '../../src/HeaderCell'; @@ -104,3 +105,23 @@ test('should use the minWidth if specified', () => { resize({ column: col2, clientXStart: 295, clientXEnd: 100, rect: { right: 300, left: 100 } }); expect(getGrid()).toHaveStyle({ gridTemplateColumns: '100px 100px' }); }); + +test('should resize column via keyboard', async () => { + function resizeCell(left: boolean) { + // eslint-disable-next-line testing-library/prefer-user-event + fireEvent.keyDown(document.activeElement!, { + keyCode: left ? '37' : '39', + ctrlKey: true, + shiftKey: true + }); + } + + setup({ columns, rows: [] }); + const [, col2] = getHeaderCells(); + await userEvent.click(col2); + expect(getGrid()).toHaveStyle({ gridTemplateColumns: '100px 200px' }); + resizeCell(false); + expect(getGrid()).toHaveStyle({ gridTemplateColumns: '100px 210px' }); + resizeCell(true); + expect(getGrid()).toHaveStyle({ gridTemplateColumns: '100px 200px' }); +});