Skip to content

Commit

Permalink
chore: update unit tests to check if the infinite loop is prevented #…
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok authored and mturoci committed Aug 17, 2023
1 parent 87611c3 commit bcf7ef6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ui/src/table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,26 @@ describe('Table.tsx', () => {
expect(emitMock).toHaveBeenCalledTimes(1)
})

it('Fires event - single selection - pre-selected value', async () => {
const
props = { ...tableProps, single: true, events: ['select'], value: 'rowname2' },
{ getAllByRole } = render(<XTable model={{ ...props }} />),
radioButtons = getAllByRole('radio')
fireEvent.click(radioButtons[0])
expect(emitMock).toHaveBeenCalledWith(tableProps.name, 'select', ['rowname1'])
expect(emitMock).toHaveBeenCalledTimes(1)
})

it('Fires event - multiple selection - select single - pre-selected values', async () => {
const
props = { ...tableProps, multiple: true, events: ['select'], values: ['rowname2', 'rowname3'] },
{ getAllByRole } = render(<XTable model={{ ...props }} />),
checkboxes = getAllByRole('checkbox')
fireEvent.click(checkboxes[1])
expect(emitMock).toHaveBeenCalledWith(tableProps.name, 'select', ['rowname1'])
expect(emitMock).toHaveBeenCalledTimes(1)
})

it('Clicks a column - link set on second col', () => {
tableProps = {
...tableProps,
Expand Down

0 comments on commit bcf7ef6

Please sign in to comment.