Skip to content

Commit

Permalink
Adding tests for REST query
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Nov 5, 2024
1 parent 9beea7d commit 5b899cc
Show file tree
Hide file tree
Showing 4 changed files with 842 additions and 603 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ThemeProvider } from '@mui/material/styles';
import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import fetchMock from 'jest-fetch-mock';
import { SnackbarProvider } from 'notistack';
import TestRouter from '__tests__/util/TestRouter';
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
import { fourteenMonthReportMock } from 'src/components/Reports/FourteenMonthReports/FourteenMonthReportMock';
import theme from 'src/theme';
import SalaryCurrencyReportPage from './[[...contactId]].page';

Expand All @@ -25,39 +26,27 @@ const TestingComponent: React.FC<TestingComponentProps> = ({
push,
};

const mocks = {
FourteenMonthReport: {
fourteenMonthReport: {
currencyGroups: [
{
contacts: [
{
id: 'contact-1',
name: 'John Doe',
lastDonationCurrency: 'USD',
pledgeCurrency: 'USD',
},
],
},
],
},
},
};

return (
<ThemeProvider theme={theme}>
<TestRouter router={router}>
<GqlMockedProvider mocks={mocks}>
<SnackbarProvider>
<SalaryCurrencyReportPage />
</SnackbarProvider>
</GqlMockedProvider>
<SnackbarProvider>
<SalaryCurrencyReportPage />
</SnackbarProvider>
</TestRouter>
</ThemeProvider>
);
};

describe('salaryCurrency page', () => {
fetchMock.enableMocks();
beforeEach(() => {
fetchMock.resetMocks();
fetchMock.mockResponses([
JSON.stringify(fourteenMonthReportMock),
{ status: 200 },
]);
process.env.REST_API_URL = 'https://api.stage.mpdx.org/api/v2/';
});
it('renders', () => {
const { getByRole } = render(<TestingComponent />);

Expand Down
Loading

0 comments on commit 5b899cc

Please sign in to comment.