Skip to content

Commit

Permalink
Sorting unit test fix #1541
Browse files Browse the repository at this point in the history
  • Loading branch information
kaperoo committed Sep 1, 2023
1 parent d1294dd commit 88d2702
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ exports[`Data column header component renders correctly with sort and filter 1`]
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -142,13 +142,13 @@ exports[`Data column header component renders correctly with sort and filter 1`]
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down Expand Up @@ -257,7 +257,7 @@ exports[`Data column header component renders correctly with sort but no filter
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -268,13 +268,13 @@ exports[`Data column header component renders correctly with sort but no filter
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Data column header component', () => {
it('sets asc order', async () => {
render(<DataHeader {...dataHeaderProps} />);
await user.click(await screen.findByRole('button', { name: 'Test' }));
expect(onSort).toHaveBeenCalledWith('test', 'asc', 'push');
expect(onSort).toHaveBeenCalledWith('test', 'asc', 'push', false);
});

it('sets desc order', async () => {
Expand All @@ -84,7 +84,7 @@ describe('Data column header component', () => {
/>
);
await user.click(await screen.findByRole('button', { name: 'Test' }));
expect(onSort).toHaveBeenCalledWith('test', 'desc', 'push');
expect(onSort).toHaveBeenCalledWith('test', 'desc', 'push', false);
});

it('sets null order', async () => {
Expand All @@ -97,19 +97,19 @@ describe('Data column header component', () => {
/>
);
await user.click(await screen.findByRole('button', { name: 'Test' }));
expect(onSort).toHaveBeenCalledWith('test', null, 'push');
expect(onSort).toHaveBeenCalledWith('test', null, 'push', false);
});
});

describe('calls the onSort method when default sort is specified', () => {
it('sets asc order', () => {
render(<DataHeader {...dataHeaderProps} defaultSort="asc" />);

expect(onSort).toHaveBeenCalledWith('test', 'asc', 'replace');
expect(onSort).toHaveBeenCalledWith('test', 'asc', 'replace', false);
});
it('sets desc order', () => {
render(<DataHeader {...dataHeaderProps} defaultSort="desc" />);
expect(onSort).toHaveBeenCalledWith('test', 'desc', 'replace');
expect(onSort).toHaveBeenCalledWith('test', 'desc', 'replace', false);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const DataHeader = React.memo(
active={true}
direction={currSortDirection}
onClick={() =>
onSort(dataKey, nextSortDirection, 'replace', shiftDown)
onSort(dataKey, nextSortDirection, 'push', shiftDown ?? false)
}
>
<Typography
Expand All @@ -95,7 +95,7 @@ const DataHeader = React.memo(
active={true}
direction={'desc'}
onClick={() => {
onSort(dataKey, nextSortDirection, 'replace', shiftDown);
onSort(dataKey, nextSortDirection, 'push', shiftDown ?? false);
setHover(false);
}}
onMouseEnter={() => setHover(true)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('Table component', () => {
it('calls onSort function when sort label clicked', async () => {
render(<Table {...tableProps} />);
await user.click(await screen.findByText('Test 1'));
expect(onSort).toHaveBeenCalledWith('TEST1', 'asc', 'push');
expect(onSort).toHaveBeenCalledWith('TEST1', 'asc', 'push', false);
});

it('calls onSort function when defaultSort has been specified', () => {
Expand All @@ -89,8 +89,8 @@ describe('Table component', () => {
};
render(<Table {...sortedTableProps} />);

expect(onSort).toHaveBeenCalledWith('TEST1', 'asc', 'replace');
expect(onSort).toHaveBeenCalledWith('TEST2', 'desc', 'replace');
expect(onSort).toHaveBeenCalledWith('TEST1', 'asc', 'replace', false);
expect(onSort).toHaveBeenCalledWith('TEST2', 'desc', 'replace', false);
});

it('renders select column correctly', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ exports[`Admin Download Status Table should render correctly 1`] = `
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -112,13 +112,13 @@ exports[`Admin Download Status Table should render correctly 1`] = `
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down Expand Up @@ -224,7 +224,7 @@ exports[`Admin Download Status Table should render correctly 1`] = `
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -235,13 +235,13 @@ exports[`Admin Download Status Table should render correctly 1`] = `
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down Expand Up @@ -347,7 +347,7 @@ exports[`Admin Download Status Table should render correctly 1`] = `
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -358,13 +358,13 @@ exports[`Admin Download Status Table should render correctly 1`] = `
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down Expand Up @@ -470,7 +470,7 @@ exports[`Admin Download Status Table should render correctly 1`] = `
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -481,13 +481,13 @@ exports[`Admin Download Status Table should render correctly 1`] = `
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down Expand Up @@ -593,7 +593,7 @@ exports[`Admin Download Status Table should render correctly 1`] = `
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -604,13 +604,13 @@ exports[`Admin Download Status Table should render correctly 1`] = `
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down Expand Up @@ -716,7 +716,7 @@ exports[`Admin Download Status Table should render correctly 1`] = `
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -727,13 +727,13 @@ exports[`Admin Download Status Table should render correctly 1`] = `
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down Expand Up @@ -1019,7 +1019,7 @@ exports[`Admin Download Status Table should render correctly 1`] = `
class="MuiBox-root css-0"
>
<span
class="MuiButtonBase-root MuiTableSortLabel-root tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
class="MuiButtonBase-root MuiTableSortLabel-root Mui-active tour-dataview-sort css-1qgma8u-MuiButtonBase-root-MuiTableSortLabel-root"
role="button"
tabindex="0"
>
Expand All @@ -1030,13 +1030,13 @@ exports[`Admin Download Status Table should render correctly 1`] = `
</p>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionAsc css-1vweko9-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="ArrowDownwardIcon"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium MuiTableSortLabel-icon MuiTableSortLabel-iconDirectionDesc css-3l415a-MuiSvgIcon-root-MuiTableSortLabel-icon"
data-testid="SortIcon"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z"
d="M3 18h6v-2H3v2zM3 6v2h18V6H3zm0 7h12v-2H3v2z"
/>
</svg>
</span>
Expand Down
Loading

0 comments on commit 88d2702

Please sign in to comment.