Skip to content

Commit

Permalink
Mock utils/chart.js to avoid late import of date-fns
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <tsmock@meta.com>
  • Loading branch information
tsmock committed Feb 8, 2024
1 parent 43ff9b1 commit d9a2d98
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import userEvent from '@testing-library/user-event';
jest.mock('react-chartjs-2', () => ({
Bar: () => null,
}));
jest.mock('../../../utils/chart');

describe('TasksStats', () => {
const setQuery = jest.fn();
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/utils/__mocks__/chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function xAxisTimeSeries() {
return { type: 'line' };
}

export { xAxisTimeSeries };
4 changes: 4 additions & 0 deletions frontend/src/views/tests/project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import { setupFaultyHandlers } from '../../network/tests/server';
import { projects } from '../../network/tests/mockData/projects';
import { MemoryRouter, Route, Routes } from 'react-router-dom';

// scrollTo is not implemented by jsdom; mock to avoid warnings.
window.scrollTo = jest.fn();

test('CreateProject renders ProjectCreate', async () => {
renderWithRouter(
<QueryParamProvider adapter={ReactRouter6Adapter}>
Expand Down Expand Up @@ -220,6 +223,7 @@ describe('Project Detail Page', () => {
Bar: () => null,
Line: () => null,
}));
jest.mock('../../utils/chart')

/**
* Set up a ProjectDetailPage given an initial entry; this avoids issues where there is no project id.
Expand Down

0 comments on commit d9a2d98

Please sign in to comment.