Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
canac committed Nov 4, 2024
1 parent 0812ab2 commit 8b8c90e
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 @@ -365,6 +365,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(
'Text Message Partner For Cultivation',
);
});

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

0 comments on commit 8b8c90e

Please sign in to comment.