diff options
author | Tayane Fernandes <tayane.rmf@gmail.com> | 2017-03-13 14:04:59 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-13 14:04:59 -0300 |
commit | ed15fdb62afb97af406fe35cc17da5d3790b7bd4 (patch) | |
tree | 34dad5108dce0b96d940792a98cb572646e5db35 /web-ui/test/integration | |
parent | 67d7d84fea07d64800a2b04a379aaa2a103b4a39 (diff) | |
parent | 471b58e945613956db951b3a7b87c9c528b152a4 (diff) |
Merge pull request #1006 from pixelated/validate-email
Email validation on the backup account page
Diffstat (limited to 'web-ui/test/integration')
-rw-r--r-- | web-ui/test/integration/backup_account.spec.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/web-ui/test/integration/backup_account.spec.js b/web-ui/test/integration/backup_account.spec.js new file mode 100644 index 00000000..b44c3b2c --- /dev/null +++ b/web-ui/test/integration/backup_account.spec.js @@ -0,0 +1,59 @@ +import { mount } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import App from 'src/common/app'; +import BackupAccountPage from 'src/backup_account/page'; +import testI18n from './i18n'; + +describe('Backup account email validation', () => { + context('Backup Account Page', () => { + let app, backupAccountPage; + + beforeEach(() => { + app = mount(<App i18n={testI18n} child={<BackupAccountPage />} />); + backupAccountPage = app.find('Page'); + }); + + context('with valid email', () => { + beforeEach(() => { + backupAccountPage.find('input').simulate('change', {target: {value: 'test@test.com'}}); + }); + + it('shows no validation error', () => { + expect(backupAccountPage.find('InputField').props().errorText).toEqual(''); + }); + + it('submit button is enabled', () => { + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(false); + }); + }); + + context('with invalid email', () => { + beforeEach(() => { + backupAccountPage.find('input').simulate('change', {target: {value: 'test'}}); + }); + + it('shows validation error', () => { + expect(backupAccountPage.find('InputField').props().errorText).toEqual('Please enter a valid email address'); + }); + + it('disables submit button', () => { + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); + }); + }); + + context('with empty email', () => { + beforeEach(() => { + backupAccountPage.find('input').simulate('change', {target: {value: ''}}); + }); + + it('shows no validation error', () => { + expect(backupAccountPage.find('InputField').props().errorText).toEqual(''); + }); + + it('disables submit button', () => { + expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true); + }); + }); + }); +}); |