Skip to content

Commit

Permalink
chore: add test for sortRef reset #1863
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Mar 27, 2023
1 parent 3ee0fbf commit bf6b145
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ui/src/table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,35 @@ describe('Table.tsx', () => {
expect(getAllByRole('gridcell')[11]).toBeUndefined()
expect(getAllByRole('gridcell')[14]).toBeUndefined()
})

it('Reset filtered items sorting after table reset', () => {
tableProps = {
...tableProps,
resettable: true,
rows: [
{ name: '3', cells: ['c', 'closed'] },
{ name: '2', cells: ['b', 'open'] },
{ name: '1', cells: ['a', 'open'] }
],
columns: [
{ name: 'colname1', label: 'Col1', sortable: true },
{ name: 'colname2', label: 'Col2', filterable: true },
],
}
const { container, getAllByText, getAllByRole, getByText } = render(<XTable model={tableProps} />)

// Sort by first column
fireEvent.click(container.querySelectorAll('.ms-DetailsHeader-cellTitle')[0])
expect(getAllByRole('gridcell')[0].textContent).toBe('a')

fireEvent.click(getByText('Reset table'))

// Open filter menu
fireEvent.click(container.querySelector('.ms-DetailsHeader-filterChevron') as HTMLElement)

fireEvent.click(getAllByText('open')[2].parentElement as HTMLDivElement)
expect(getAllByRole('gridcell')[0].textContent).toBe('b')
})
})

describe('search', () => {
Expand Down

0 comments on commit bf6b145

Please sign in to comment.