Skip to content

Commit

Permalink
Fixes broken tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
wjames111 committed Oct 24, 2024
1 parent 0cc5ffc commit 3dff50e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,15 @@ describe('ResultSelect', () => {
completedAction: ActivityTypeEnum.FollowUpTextMessage,
});
});
it('preselects a result when only one result is available', () => {
const { getByRole } = render(
<Components availableResults={[ResultEnum.Attempted]} />,
);
expect(getByRole('combobox', { name: 'Result' })).toBeInTheDocument();
expect(getByRole('combobox', { name: 'Result' })).toHaveValue('Attempted');
it('preselects a result when only one result is available', async () => {
render(<Components availableResults={[ResultEnum.Completed]} />);

expect(handleResultChange).toHaveBeenCalledWith({
result: ResultEnum.Completed,
setFieldValue,
setResultSelected,
phaseData,
completedAction: ActivityTypeEnum.FollowUpTextMessage,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const ResultAutocomplete: React.FC<ResultAutocompleteProps> = ({
setFieldValue,
setResultSelected,
phaseData,
completedAction,
});
}
}, [availableResults]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ describe('TaskModalLogForm', () => {
expect(queryByLabelText('Comment')).not.toBeInTheDocument();
expect(queryByLabelText('Tags')).not.toBeInTheDocument();
expect(queryByLabelText('Assignee')).not.toBeInTheDocument();
expect(queryByLabelText('Next Action')).not.toBeInTheDocument();
userEvent.click(getByLabelText('Show More'));
expect(getByLabelText('Comment')).toBeInTheDocument();
userEvent.type(getByLabelText('Comment'), 'test comment');
Expand Down
27 changes: 21 additions & 6 deletions src/components/Task/Modal/Form/TaskModalTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ type Components = ({
props,
}: ComponentsProps) => JSX.Element;

const options = [
'None',
'Phone Call',
'Email',
'Text Message',
'Social Media',
'In Person',
'Thank You Note',
'Digital Newsletter',
'Physical Newsletter',
'Prayer Request',
'Update Information',
'To Do',
];

// eslint-disable-next-line jest/no-export
export const taskModalTests = (Components: Components) => {
describe('Task Modal Results +Next Action', () => {
Expand Down Expand Up @@ -261,15 +276,15 @@ export const taskModalTests = (Components: Components) => {
ActivityTypeEnum.PartnerCareEmail,
);
expect(results).toEqual([]);
expect(nextActions).toEqual([]);
expect(nextActions).toEqual(options);
});

it('as correct options for PartnerCarePhysicalNewsletter', async () => {
const { results, nextActions } = await getOptions(
ActivityTypeEnum.PartnerCarePhysicalNewsletter,
);
expect(results).toEqual([]);
expect(nextActions).toEqual([]);
expect(nextActions).toEqual(options);
});

it('has correct options for NONE', async () => {
Expand All @@ -283,15 +298,15 @@ export const taskModalTests = (Components: Components) => {
ActivityTypeEnum.PartnerCarePrayerRequest,
);
expect(results).toEqual([]);
expect(nextActions).toEqual([]);
expect(nextActions).toEqual(options);
});

it('has correct options for PartnerCarePhoneCall', async () => {
const { results, nextActions } = await getOptions(
ActivityTypeEnum.PartnerCarePhoneCall,
);
expect(results).toEqual([]);
expect(nextActions).toEqual([]);
expect(nextActions).toEqual(options);
});

it('has correct options for InitiationLetter', async () => {
Expand All @@ -307,15 +322,15 @@ export const taskModalTests = (Components: Components) => {
ActivityTypeEnum.PartnerCareThank,
);
expect(results).toEqual([]);
expect(nextActions).toEqual([]);
expect(nextActions).toEqual(options);
});

it('has correct options for PartnerCareToDo', async () => {
const { results, nextActions } = await getOptions(
ActivityTypeEnum.PartnerCareToDo,
);
expect(results).toEqual([]);
expect(nextActions).toEqual([]);
expect(nextActions).toEqual(options);
});
});
};

0 comments on commit 3dff50e

Please sign in to comment.