Skip to content

Commit

Permalink
Use simulate('submit') instead of 'click' to submit form
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyyap committed Jan 15, 2018
1 parent b7709df commit 395e4c4
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('Scribing question', () => {

await sleep(1);
newPage.update();
newPage.find('[type="submit"]').first().simulate('click');
newPage.find('button').first().simulate('submit');

await sleep(1);
expect(spyCreate).toHaveBeenCalled();
Expand All @@ -211,7 +211,7 @@ describe('Scribing question', () => {
it('allows question to be updated', async () => {
Object.defineProperty(window.location, 'pathname', {
writable: true,
value: `/courses/${courseId}/assessments/${assessmentId}/question/scribing/${scribingId}`,
value: `/courses/${courseId}/assessments/${assessmentId}/question/scribing/${scribingId}/edit`,
});

const spyUpdate = jest.spyOn(CourseAPI.question.scribing.scribings, 'update');
Expand All @@ -223,16 +223,16 @@ describe('Scribing question', () => {
<ProviderWrapper store={store}>
<MemoryRouter
initialEntries={[`/courses/${courseId}/assessments/${assessmentId}
/question/scribing/${scribingId}`]}
/question/scribing/${scribingId}/edit`]}
>
<ScribingQuestion initialValues={mockFields} />
<ScribingQuestion />
</MemoryRouter>
</ProviderWrapper>
);

await sleep(1);
fetchPage.update();
fetchPage.find('[type="submit"]').first().simulate('click');
fetchPage.find('button').first().simulate('submit');

await sleep(1);
expect(spyUpdate).toHaveBeenCalledWith(scribingId, mockUpdatedFields);
Expand Down

0 comments on commit 395e4c4

Please sign in to comment.