Skip to content

Commit

Permalink
feat: update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
amlannandy committed Dec 7, 2024
1 parent 4e20bc6 commit 20a0680
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable sonarjs/no-duplicate-string */
import ROUTES from 'constants/routes';
import DashboardsList from 'container/ListOfDashboard';
import * as dashboardUtils from 'container/NewDashboard/DashboardDescription';
import {
dashboardEmptyState,
dashboardSuccessResponse,
Expand All @@ -11,6 +12,10 @@ import { DashboardProvider } from 'providers/Dashboard/Dashboard';
import { MemoryRouter, useLocation } from 'react-router-dom';
import { fireEvent, render, waitFor } from 'tests/test-utils';

jest.mock('container/NewDashboard/DashboardDescription', () => ({
sanitizeDashboardData: jest.fn(),
}));

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useLocation: jest.fn(),
Expand Down Expand Up @@ -208,7 +213,7 @@ describe('dashboard list page', () => {
);
});

it('ensure that the popover actions on each list item renders list of options', async () => {
it('ensure that the popover action renders list of options and export JSON works correctly', async () => {
const { getByText, getAllByTestId } = render(
<MemoryRouter initialEntries={['/dashbords']}>
<DashboardProvider>
Expand All @@ -226,5 +231,8 @@ describe('dashboard list page', () => {
expect(getByText('View')).toBeInTheDocument();
expect(getByText('Copy Link')).toBeInTheDocument();
expect(getByText('Export JSON')).toBeInTheDocument();

fireEvent.click(getByText('Export JSON'));
expect(dashboardUtils.sanitizeDashboardData).toHaveBeenCalled();
});
});

0 comments on commit 20a0680

Please sign in to comment.