diff options
Diffstat (limited to 'web-ui/src/backup_account/page.spec.js')
-rw-r--r-- | web-ui/src/backup_account/page.spec.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/web-ui/src/backup_account/page.spec.js b/web-ui/src/backup_account/page.spec.js index ece61336..334d3ba8 100644 --- a/web-ui/src/backup_account/page.spec.js +++ b/web-ui/src/backup_account/page.spec.js @@ -22,4 +22,59 @@ describe('BackupAccount', () => { it('renders backup account submit button', () => { expect(page.find('SubmitButton').props().buttonText).toEqual('backup-account.button'); }); + + describe('Email validation', () => { + let pageInstance; + + beforeEach(() => { + pageInstance = page.instance(); + }); + + it('verify initial state', () => { + expect(pageInstance.state.error).toEqual(''); + expect(page.find('SubmitButton').props().disabled).toEqual(true); + }); + + context('with invalid email', () => { + beforeEach(() => { + pageInstance.validateEmail({ target: { value: 'test' } }); + }); + + it('sets error in state', () => { + expect(pageInstance.state.error).toEqual('backup-account.error.invalid-email'); + }); + + it('disables submit button', () => { + expect(page.find('SubmitButton').props().disabled).toEqual(true); + }); + }); + + context('with valid email', () => { + beforeEach(() => { + pageInstance.validateEmail({ target: { value: 'test@test.com' } }); + }); + + it('does not set error in state', () => { + expect(pageInstance.state.error).toEqual(''); + }); + + it('submit button is enabled', () => { + expect(page.find('SubmitButton').props().disabled).toEqual(false); + }); + }); + + context('with empty email', () => { + beforeEach(() => { + pageInstance.validateEmail({ target: { value: '' } }); + }); + + it('not set error in state', () => { + expect(pageInstance.state.error).toEqual(''); + }); + + it('disables submit button', () => { + expect(page.find('SubmitButton').props().disabled).toEqual(true); + }); + }); + }); }); |