diff options
author | Sriram Viswanathan <sriramv@thoughtworks.com> | 2017-03-10 17:36:24 -0300 |
---|---|---|
committer | Sriram Viswanathan <sriramv@thoughtworks.com> | 2017-03-10 17:36:24 -0300 |
commit | def51d0d4265e9a489d05ca8cb4bec6abb26073f (patch) | |
tree | 9a6567736a3e64ea56dda83d39da4031bb107d16 /web-ui/src/backup_account | |
parent | 908806ee4d2e94c691f8fb7f4ada6d45e7e9a282 (diff) |
[#923] Separate out asserts into different tests
with @tayanefernandes
Diffstat (limited to 'web-ui/src/backup_account')
-rw-r--r-- | web-ui/src/backup_account/page.spec.js | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/web-ui/src/backup_account/page.spec.js b/web-ui/src/backup_account/page.spec.js index f3590ed8..334d3ba8 100644 --- a/web-ui/src/backup_account/page.spec.js +++ b/web-ui/src/backup_account/page.spec.js @@ -35,22 +35,46 @@ describe('BackupAccount', () => { expect(page.find('SubmitButton').props().disabled).toEqual(true); }); - it('should set error in state and disabled submit button when email is invalid', () => { - pageInstance.validateEmail({ target: { value: 'test' } }); - expect(pageInstance.state.error).toEqual('backup-account.error.invalid-email'); - 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); + }); }); - it('should not set error in state and submit button is enabled when email is valid', () => { - pageInstance.validateEmail({ target: { value: 'test@test.com' } }); - expect(pageInstance.state.error).toEqual(''); - expect(page.find('SubmitButton').props().disabled).toEqual(false); + 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); + }); }); - it('should not set error in state and disable submit button when email is empty', () => { - pageInstance.validateEmail({ target: { value: '' } }); - expect(pageInstance.state.error).toEqual(''); - expect(page.find('SubmitButton').props().disabled).toEqual(true); + 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); + }); }); }); }); |