Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Nov 15, 2024
1 parent 97fb5b2 commit 0825d35
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import userEvent from '@testing-library/user-event';
import { SnackbarProvider } from 'notistack';
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
import { GetDesignationAccountsQuery } from 'src/components/EditDonationModal/EditDonationModal.generated';
import { GetDonorAccountsQuery } from 'src/components/common/DonorAccountAutocomplete/DonorAccountAutocomplete.generated';
import theme from '../../../../../../../../theme';
import { AddDonation } from './AddDonation';
import { AddDonationMutation } from './AddDonation.generated';
Expand Down Expand Up @@ -58,7 +59,11 @@ describe('AddDonation', () => {
<LocalizationProvider dateAdapter={AdapterLuxon}>
<ThemeProvider theme={theme}>
<SnackbarProvider>
<GqlMockedProvider<{ AddDonation: AddDonationMutation }>
<GqlMockedProvider<{
AddDonation: AddDonationMutation;
GetDesignationAccounts: GetDesignationAccountsQuery;
GetDonorAccounts: GetDonorAccountsQuery;
}>
onCall={mutationSpy}
mocks={{
GetDonationModal: {
Expand Down Expand Up @@ -91,8 +96,7 @@ describe('AddDonation', () => {
accountListDonorAccounts: [
{
id: 'donor-acc-1',
accountNumber: 'acct-01',
displayName: 'Cool Donor Account',
name: 'Cool Donor Account',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@ import React from 'react';
import { ThemeProvider } from '@mui/material/styles';
import userEvent from '@testing-library/user-event';
import { ApolloErgonoMockMap } from 'graphql-ergonomock';
import { DeepPartial } from 'ts-essentials';
import TestRouter from '__tests__/util/TestRouter';
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
import { render, waitFor } from '__tests__/util/testingLibraryReactMock';
import { LoadCoachingListQuery } from 'src/components/Coaching/LoadCoachingList.generated';
import theme from 'src/theme';
import { GetToolNotificationsQuery } from './GetToolNotifcations.generated';
import NavMenu from './NavMenu';

const accountListId = 'test121';

interface TestComponentProps {
router?: Partial<NextRouter>;
mocks?: ApolloErgonoMockMap;
mocks?: ApolloErgonoMockMap &
DeepPartial<{
GetToolNotifications: GetToolNotificationsQuery;
LoadCoachingList: LoadCoachingListQuery;
}>;
}

const TestComponent: React.FC<TestComponentProps> = ({ router, mocks }) => (
Expand Down Expand Up @@ -192,18 +199,13 @@ describe('NavMenu', () => {
<TestComponent
mocks={{
GetToolNotifications: {
contacts: {
totalCount: 0,
},
people: {
totalCount: 0,
},
contactDuplicates: {
totalCount: 0,
},
personDuplicates: {
totalCount: 0,
},
fixCommitmentInfo: { totalCount: 0 },
fixMailingAddresses: { totalCount: 0 },
fixSendNewsletter: { totalCount: 0 },
fixEmailAddresses: { totalCount: 0 },
fixPhoneNumbers: { totalCount: 0 },
mergeContacts: { totalCount: 0 },
mergePeople: { totalCount: 0 },
},
}}
/>,
Expand All @@ -227,18 +229,13 @@ describe('NavMenu', () => {
<TestComponent
mocks={{
GetToolNotifications: {
contacts: {
totalCount: 1,
},
people: {
totalCount: 1,
},
contactDuplicates: {
totalCount: 1,
},
personDuplicates: {
totalCount: 1,
},
fixCommitmentInfo: { totalCount: 1 },
fixMailingAddresses: { totalCount: 1 },
fixSendNewsletter: { totalCount: 1 },
fixEmailAddresses: { totalCount: 1 },
fixPhoneNumbers: { totalCount: 1 },
mergeContacts: { totalCount: 1 },
mergePeople: { totalCount: 1 },
},
}}
/>,
Expand All @@ -263,18 +260,13 @@ describe('NavMenu', () => {
<TestComponent
mocks={{
GetToolNotifications: {
contacts: {
totalCount: 30,
},
people: {
totalCount: 30,
},
contactDuplicates: {
totalCount: 130,
},
personDuplicates: {
totalCount: 30,
},
fixCommitmentInfo: { totalCount: 30 },
fixMailingAddresses: { totalCount: 30 },
fixSendNewsletter: { totalCount: 30 },
fixEmailAddresses: { totalCount: 30 },
fixPhoneNumbers: { totalCount: 30 },
mergeContacts: { totalCount: 130 },
mergePeople: { totalCount: 30 },
},
}}
/>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const onChange = jest.fn();
const mocks = {
GetDonorAccounts: {
accountListDonorAccounts: [
{ id: 'donor-1', displayName: 'Donor 1' },
{ id: 'donor-2', displayName: 'Donor 2' },
{ id: 'donor-3', displayName: 'Donor 3' },
{ id: 'donor-1', name: 'Donor 1' },
{ id: 'donor-2', name: 'Donor 2' },
{ id: 'donor-3', name: 'Donor 3' },
],
},
};
Expand Down

0 comments on commit 0825d35

Please sign in to comment.