Skip to content

Commit c4bd664

Browse files
committed
test: add suggested test
1 parent 28e3729 commit c4bd664

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

packages/table-core/tests/RowSelection.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,5 +767,24 @@ describe('RowSelection', () => {
767767
const firstRow = table.getCoreRowModel().rows[0]
768768
expect(firstRow.getIsAllSubRowsSelected()).toBe(true)
769769
})
770+
771+
it('should return true when all selectable sub-rows are selected and some are non-selectable', () => {
772+
const data = makeData(1, 2)
773+
const columns = generateColumns(data)
774+
775+
const table = createTable<Person>({
776+
enableRowSelection: (row) => row.id !== '0.1', // second sub-row is NOT selectable
777+
onStateChange() {},
778+
renderFallbackValue: '',
779+
data,
780+
getSubRows: (row) => row.subRows,
781+
state: { rowSelection: { '0.0': true } }, // only selectable sub-row selected
782+
columns,
783+
getCoreRowModel: getCoreRowModel(),
784+
})
785+
786+
const firstRow = table.getCoreRowModel().rows[0]
787+
expect(firstRow.getIsAllSubRowsSelected()).toBe(true)
788+
})
770789
});
771790
})

0 commit comments

Comments
 (0)