feat: update unit test

This commit is contained in:
amlannandy 2024-12-07 11:22:10 +05:30 committed by Amlan Kumar Nandy
parent 1b8213653a
commit 2508e6f9f1

View File

@ -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,
@ -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(),
@ -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>
@ -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();
});
});