forked from openedx/frontend-app-communications
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: change email learnerns logic and new test case for BuilkEma…
…ilForm
- Loading branch information
Showing
2 changed files
with
34 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,4 +170,31 @@ describe('bulk-email-form', () => { | |
fireEvent.click(continueButton); | ||
expect(dispatchMock).toHaveBeenCalled(); | ||
}); | ||
test('learnersEmailList state is updated correctly', () => { | ||
const { getByTestId } = render( | ||
renderBulkEmailFormContext({ | ||
editor: { | ||
editMode: true, | ||
emailBody: 'test', | ||
emailSubject: 'test', | ||
emailRecipients: ['test'], | ||
scheduleDate: formatDate(tomorrow), | ||
scheduleTime: '10:00', | ||
schedulingId: 1, | ||
emailId: 1, | ||
isLoading: false, | ||
errorRetrievingData: false, | ||
}, | ||
}), | ||
); | ||
|
||
const learnersEmailAddButton = getByTestId('learners-email-add-button'); | ||
const emailLearnerInput = getByTestId('learners-email-input'); | ||
fireEvent.change(emailLearnerInput, { target: { value: '[email protected]' } }); | ||
expect(emailLearnerInput.value).toBe('[email protected]'); | ||
fireEvent.click(learnersEmailAddButton); | ||
// clean the input after adding an email learner | ||
expect(emailLearnerInput.value).toBe(''); | ||
expect(dispatchMock).toHaveBeenCalled(); | ||
}); | ||
}); |