Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Oct 31, 2024
1 parent bb7e3fc commit ae31336
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/components/Task/Modal/Form/TaskModalForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,55 @@ describe('TaskModalForm', () => {
);
});

it('defaults the subject to the defaultValues subject', () => {
const { getByRole } = render(
<LocalizationProvider dateAdapter={AdapterLuxon}>
<SnackbarProvider>
<GqlMockedProvider>
<TaskModalForm
defaultValues={{
taskPhase: PhaseEnum.PartnerCare,
activityType: ActivityTypeEnum.PartnerCareTextMessage,
subject: 'Do something',
}}
accountListId={accountListId}
onClose={onClose}
task={null}
/>
</GqlMockedProvider>
</SnackbarProvider>
</LocalizationProvider>,
);

expect(getByRole('textbox', { name: 'Subject' })).toHaveValue(
'Do something',
);
});

it('defaults the subject to the name based on phase and action', () => {
const { getByRole } = render(
<LocalizationProvider dateAdapter={AdapterLuxon}>
<SnackbarProvider>
<GqlMockedProvider>
<TaskModalForm
defaultValues={{
taskPhase: PhaseEnum.PartnerCare,
activityType: ActivityTypeEnum.PartnerCareTextMessage,
}}
accountListId={accountListId}
onClose={onClose}
task={null}
/>
</GqlMockedProvider>
</SnackbarProvider>
</LocalizationProvider>,
);

expect(getByRole('textbox', { name: 'Subject' })).toHaveValue(
'Partner Care - Text Message',
);
});

it('renders fields for completed task', async () => {
const { getByRole, findByRole, queryByText } = render(
<ThemeProvider theme={theme}>
Expand Down

0 comments on commit ae31336

Please sign in to comment.