From def51d0d4265e9a489d05ca8cb4bec6abb26073f Mon Sep 17 00:00:00 2001 From: Sriram Viswanathan Date: Fri, 10 Mar 2017 17:36:24 -0300 Subject: [#923] Separate out asserts into different tests with @tayanefernandes --- web-ui/src/backup_account/page.spec.js | 48 +++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 12 deletions(-) (limited to 'web-ui/src/backup_account') 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); + }); }); }); }); -- cgit v1.2.3