diff options
author | Anike Arni <aarni@thoughtworks.com> | 2017-03-30 17:23:41 -0300 |
---|---|---|
committer | Anike Arni <aarni@thoughtworks.com> | 2017-03-31 18:29:48 -0300 |
commit | 7be03150100d319c6d373241f614a29b374cb74d (patch) | |
tree | 90a553dfa0b6f119300a00e6ef02788923035e5c /web-ui/src/account_recovery/new_password_form/new_password_form.spec.js | |
parent | f40808a147d1135e8bbee6d78306a598cf5ca647 (diff) |
[#935] Submits user recovery code to new endpoint
with @deniscostadsc
Diffstat (limited to 'web-ui/src/account_recovery/new_password_form/new_password_form.spec.js')
-rw-r--r-- | web-ui/src/account_recovery/new_password_form/new_password_form.spec.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/web-ui/src/account_recovery/new_password_form/new_password_form.spec.js b/web-ui/src/account_recovery/new_password_form/new_password_form.spec.js index d2bd350c..5ffd9720 100644 --- a/web-ui/src/account_recovery/new_password_form/new_password_form.spec.js +++ b/web-ui/src/account_recovery/new_password_form/new_password_form.spec.js @@ -1,6 +1,7 @@ import { shallow } from 'enzyme'; import expect from 'expect'; import React from 'react'; +import fetchMock from 'fetch-mock'; import { NewPasswordForm } from './new_password_form'; describe('NewPasswordForm', () => { @@ -11,7 +12,7 @@ describe('NewPasswordForm', () => { const mockTranslations = key => key; mockPrevious = expect.createSpy(); newPasswordForm = shallow( - <NewPasswordForm t={mockTranslations} previous={mockPrevious} /> + <NewPasswordForm t={mockTranslations} previous={mockPrevious} userCode='def234' /> ); }); @@ -37,4 +38,19 @@ describe('NewPasswordForm', () => { newPasswordForm.find('BackLink').simulate('click'); expect(mockPrevious).toHaveBeenCalled(); }); + + describe('Submit', () => { + beforeEach(() => { + fetchMock.post('/account-recovery', 200); + newPasswordForm.find('form').simulate('submit', { preventDefault: expect.createSpy() }); + }); + + it('posts to account recovery', () => { + expect(fetchMock.called('/account-recovery')).toBe(true, 'POST was not called'); + }); + + it('sends user code as content', () => { + expect(fetchMock.lastOptions('/account-recovery').body).toContain('"userCode":"def234"'); + }); + }); }); |