Skip to content

Commit

Permalink
test(data-table): update test (#1230)
Browse files Browse the repository at this point in the history
  • Loading branch information
XieZongChen authored Sep 24, 2021
1 parent 2ff3ba8 commit 47fde6b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/data-table/tests/DataTable.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,39 @@ describe('n-data-table', () => {
'n-data-table--flex-height'
)
})

it('should work with `row-class-name` prop', async () => {
const columns = [
{
title: 'Name',
key: 'name'
}
]
const data = new Array(978).fill(0).map((_, index) => {
return {
name: index
}
})
const getRowClassName = (rowData: any, index: number): string => {
return `${index}-test`
}
let wrapper = mount(() => <NDataTable columns={columns} data={data} />)
expect(wrapper.find('tbody .n-data-table-tr').classes()).not.toContain(
'test'
)

wrapper = mount(() => (
<NDataTable columns={columns} data={data} rowClassName="test" />
))
expect(wrapper.find('tbody .n-data-table-tr').classes()).toContain('test')

wrapper = mount(() => (
<NDataTable
columns={columns}
data={data}
rowClassName={getRowClassName}
/>
))
expect(wrapper.find('tbody .n-data-table-tr').classes()).toContain('0-test')
})
})

0 comments on commit 47fde6b

Please sign in to comment.