Skip to content

Commit

Permalink
Test coverage for statusTitle.
Browse files Browse the repository at this point in the history
  • Loading branch information
wjames111 committed Sep 5, 2024
1 parent 058c433 commit 4e78626
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/components/Tool/FixCommitmentInfo/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ interface Props {
id: string;
name: string;
donations: DonationsType[];
statusTitle: string;
statusTitle: string | null | undefined;
statusValue: string;
amount: number;
amountCurrency: string;
Expand Down Expand Up @@ -304,7 +304,7 @@ const Contact: React.FC<Props> = ({
<Typography variant="subtitle1">{name}</Typography>
</Link>
<Typography variant="subtitle2">
{`Current: ${statusTitle} ${
{`Current: ${statusTitle || ''} ${
amount && amountCurrency
? currencyFormat(amount, amountCurrency, locale)
: ''
Expand Down
25 changes: 24 additions & 1 deletion src/components/Tool/FixCommitmentInfo/FixCommitmentInfo.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,16 @@ describe('FixCommitmentContact', () => {
});

it('default with test data', async () => {
const { getByText, findByText } = render(<Components />);
const { getByText, getAllByText, findByText } = render(<Components />);
await findByText('Fix Commitment Info');
expect(getByText('Fix Commitment Info')).toBeInTheDocument();

expect(
getByText('You have 2 partner statuses to confirm.'),
).toBeInTheDocument();
expect(getAllByText('Current: Partner - Financial $1 Weekly')).toHaveLength(
2,
);
});

it('has correct styles', async () => {
Expand Down Expand Up @@ -179,4 +182,24 @@ describe('FixCommitmentContact', () => {

expect(setContactFocus).toHaveBeenCalled();
});

it('updates contact info with dontChange enum', async () => {
const { findAllByTestId, findByText, getAllByTestId, queryByText } = render(
<Components />,
);

userEvent.click((await findAllByTestId('doNotChangeButton'))[0]);

expect(
await findByText(
"Are you sure you wish to leave Tester 1's commitment information unchanged?",
),
).toBeInTheDocument();

userEvent.click(getAllByTestId('action-button')[1]);

await waitFor(() =>
expect(queryByText('Tester 1')).not.toBeInTheDocument(),
);
});
});
5 changes: 2 additions & 3 deletions src/components/Tool/FixCommitmentInfo/FixCommitmentInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,8 @@ const FixCommitmentInfo: React.FC<Props> = ({
key={contact.id}
donations={contact.donations?.nodes}
statusTitle={
contact.status
? contactPartnershipStatus[contact.status]
: ''
contact.status &&
contactPartnershipStatus[contact.status]
}
statusValue={
getLocalizedContactStatus(t, contact.status) || ''
Expand Down

0 comments on commit 4e78626

Please sign in to comment.