From dd9fc303785823d3d94d61c3b96a50d414715d9e Mon Sep 17 00:00:00 2001 From: Marek Mihok Date: Tue, 15 Aug 2023 22:51:50 +0200 Subject: [PATCH] chore: update unit tests to check if the infinite loop is prevented #2069 --- ui/src/table.test.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/src/table.test.tsx b/ui/src/table.test.tsx index 5678127073f..d08714d39c5 100644 --- a/ui/src/table.test.tsx +++ b/ui/src/table.test.tsx @@ -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(), + 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(), + 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,