Skip to content

Commit

Permalink
Fix empty message test
Browse files Browse the repository at this point in the history
  • Loading branch information
ErlingHauan committed May 13, 2024
1 parent 06f5f7f commit 67f626e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ const rows = [
icon: <StarFillIcon />,
name: 'Coordinated register notification',
creator: 'Brønnøysund Register Centre',
lastChanged: new Date('2023-04-12').toLocaleDateString(),
lastChanged: '12-04-2023',
},
{
id: 2,
icon: <StarFillIcon />,
name: 'Application for authorisation and license as a healthcare personnel',
creator: 'The Norwegian Directorate of Health',
lastChanged: new Date('2023-04-05').toLocaleDateString(),
lastChanged: '05-04-2023',
},
];
```
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,6 @@ describe('StudioTableLocalPagination', () => {
emptyTableMessage='No rows to display'
/>,
);
expect(screen.getByRole('paragraph', { value: 'No rows to display' })).toBeInTheDocument();
expect(screen.getByText('No rows to display')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ export const StudioTableLocalPagination = forwardRef<
useEffect(() => {
const newRowsToRender = getRowsToRender(currentPage, pageSize, sortedRows || rows);

const outOfRange = !newRowsToRender.length && currentPage > 1;
if (outOfRange) {
const isOutOfRange = !newRowsToRender.length && currentPage > 1;
if (isOutOfRange) {
setCurrentPage(1);
setRowsToRender(getRowsToRender(1, pageSize, sortedRows || rows));
return;
}

setRowsToRender(newRowsToRender);
}, [sortedRows, currentPage, pageSize]);
}, [sortedRows, rows, currentPage, pageSize]);

const totalPages = Math.ceil(rows.length / pageSize);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { propInfoColumns, propInfoRowsRemotePagination } from './mockData';
<Paragraph>
StudioTableRemotePagination brings together Digdir Designsystemet's `Table` and `Pagination`
components. This component is useful when data is retrieved in chunks, and the pagination logic is
managed externally.{' '}
managed externally.
</Paragraph>

<Canvas of={StudioTableRemotePaginationStories.Preview} />
Expand Down Expand Up @@ -61,14 +61,14 @@ const rows = [
icon: <StarFillIcon />,
name: 'Coordinated register notification',
creator: 'Brønnøysund Register Centre',
lastChanged: new Date('2023-04-12').toLocaleDateString(),
lastChanged: '12-04-2023',
},
{
id: 2,
icon: <StarFillIcon />,
name: 'Application for authorisation and license as a healthcare personnel',
creator: 'The Norwegian Directorate of Health',
lastChanged: new Date('2023-04-05').toLocaleDateString(),
lastChanged: '05-04-2023',
},
];
```
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ describe('StudioTableRemotePagination', () => {
emptyTableMessage='No rows to display'
/>,
);
expect(screen.getByRole('paragraph', { value: 'No rows to display' })).toBeInTheDocument();
expect(screen.getByText('No rows to display')).toBeInTheDocument();
});
});

0 comments on commit 67f626e

Please sign in to comment.