From 82ee0994d2f16970f627300f3b82f64de7755c8d Mon Sep 17 00:00:00 2001 From: Joel 'Aaron' Cohen Date: Mon, 4 Nov 2024 16:54:31 -0500 Subject: [PATCH] Add failing test showing row is selected with no selectable subRows --- .../table-core/tests/RowSelection.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/table-core/tests/RowSelection.test.ts b/packages/table-core/tests/RowSelection.test.ts index 38bdfb7dcb..fce795af08 100644 --- a/packages/table-core/tests/RowSelection.test.ts +++ b/packages/table-core/tests/RowSelection.test.ts @@ -201,6 +201,34 @@ describe('RowSelection', () => { expect(result).toEqual(false) }) + it('should return false if no sub-rows are selectable', () => { + const data = makeData(3, 2) + const columns = generateColumns(data) + + const table = createTable({ + enableRowSelection: false, + onStateChange() {}, + renderFallbackValue: '', + data, + getSubRows: row => row.subRows, + state: { + rowSelection: {}, + }, + columns, + getCoreRowModel: getCoreRowModel(), + }) + + const firstRow = table.getCoreRowModel().rows[0] + + const result = RowSelection.isSubRowSelected( + firstRow, + table.getState().rowSelection, + table + ) + + expect(result).toEqual(false) + }) + it('should return some if some sub-rows are selected', () => { const data = makeData(3, 2) const columns = generateColumns(data)