Skip to content

Commit

Permalink
Add failing test showing row is selected with no selectable subRows
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel 'Aaron' Cohen committed Nov 4, 2024
1 parent 6b4d616 commit 453dc71
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions packages/table-core/tests/RowSelection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: true,
onStateChange() {},
onStateChange() { },
renderFallbackValue: '',
data,
getSubRows: row => row.subRows,
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: true,
onStateChange() {},
onStateChange() { },
renderFallbackValue: '',
data,
getSubRows: row => row.subRows,
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: true,
onStateChange() {},
onStateChange() { },
renderFallbackValue: '',
data,
getSubRows: row => row.subRows,
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: true,
onStateChange() {},
onStateChange() { },
renderFallbackValue: '',
data,
state: {},
Expand All @@ -179,7 +179,35 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: true,
onStateChange() {},
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 false if no sub-rows are selectable', () => {
const data = makeData(3, 2)
const columns = generateColumns(data)

const table = createTable<Person>({
enableRowSelection: false,
onStateChange() { },
renderFallbackValue: '',
data,
getSubRows: row => row.subRows,
Expand Down Expand Up @@ -207,7 +235,7 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: true,
onStateChange() {},
onStateChange() { },
renderFallbackValue: '',
data,
getSubRows: row => row.subRows,
Expand Down Expand Up @@ -237,7 +265,7 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: true,
onStateChange() {},
onStateChange() { },
renderFallbackValue: '',
data,
getSubRows: row => row.subRows,
Expand Down Expand Up @@ -267,7 +295,7 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: row => row.index === 0, // only first row is selectable (of 2 sub-rows)
onStateChange() {},
onStateChange() { },
renderFallbackValue: '',
data,
getSubRows: row => row.subRows,
Expand Down Expand Up @@ -296,7 +324,7 @@ describe('RowSelection', () => {

const table = createTable<Person>({
enableRowSelection: true,
onStateChange() {},
onStateChange() { },
renderFallbackValue: '',
data,
getSubRows: row => row.subRows,
Expand Down

0 comments on commit 453dc71

Please sign in to comment.