diff options
author | Tulio Casagrande <tuliocasagrande@gmail.com> | 2017-04-04 13:14:34 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-04 13:14:34 -0300 |
commit | f70c2827d41d1d805d6446670b861b7abf0761b1 (patch) | |
tree | df266fda0c593a27c568215716d48d9994fbd344 /web-ui/src/account_recovery/new_password_form/new_password_form.spec.js | |
parent | af454c71da106644eee644c4286bbae4788b8e14 (diff) | |
parent | d7914b9b5640c3d85c6230a032180b2e64520bca (diff) |
Merge pull request #1042 from pixelated/login-recovery-code
[#935] Sends user recovery code and password to account recovery endpoint
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 | 28 |
1 files changed, 27 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..26b8651c 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,29 @@ describe('NewPasswordForm', () => { newPasswordForm.find('BackLink').simulate('click'); expect(mockPrevious).toHaveBeenCalled(); }); + + describe('Submit', () => { + beforeEach(() => { + fetchMock.post('/account-recovery', 200); + newPasswordForm.find('InputField[name="new-password"]').simulate('change', { target: { value: '123' } }); + newPasswordForm.find('InputField[name="confirm-password"]').simulate('change', { target: { value: '456' } }); + 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"'); + }); + + it('sends password as content', () => { + expect(fetchMock.lastOptions('/account-recovery').body).toContain('"password":"123"'); + }); + + it('sends password confirmation as content', () => { + expect(fetchMock.lastOptions('/account-recovery').body).toContain('"confirmation":"456"'); + }); + }); }); |