Skip to content

Commit

Permalink
chore: add performance test
Browse files Browse the repository at this point in the history
  • Loading branch information
bwittenberg committed Jun 4, 2024
1 parent 3370857 commit ff47283
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion packages/react/src/DataTable/__tests__/DataTable.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import userEvent from '@testing-library/user-event'
import {render, screen, queryAllByRole} from '@testing-library/react'
import React from 'react'
import React, {Profiler, type ComponentProps} from 'react'
import {DataTable, Table} from '../../DataTable'
import type {Column} from '../column'
import {createColumnHelper} from '../column'
Expand Down Expand Up @@ -1036,4 +1036,30 @@ describe('DataTable', () => {
})
})
})

describe('performance tests', () => {
it('should not render twice on initial render', () => {
type Data = {id: string; value: string}
const columns: ComponentProps<typeof DataTable<Data>>['columns'] = [
{
header: 'Value',
field: 'value',
},
]
const data: ComponentProps<typeof DataTable<Data>>['data'] = [
{
id: '1',
value: 'one',
},
]
let renderCount = 0
render(
<Profiler id="DataTable" onRender={() => renderCount++}>
<DataTable data={data} columns={columns} />
</Profiler>,
)

expect(renderCount).toBe(1)
})
})
})

0 comments on commit ff47283

Please sign in to comment.