Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon Ko committed Oct 9, 2023
1 parent a2c31e7 commit 2734915
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/column/resizable.test.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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' });
});

0 comments on commit 2734915

Please sign in to comment.