summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorSriram Viswanathan <sriramv@thoughtworks.com>2017-03-10 17:36:24 -0300
committerSriram Viswanathan <sriramv@thoughtworks.com>2017-03-10 17:36:24 -0300
commitdef51d0d4265e9a489d05ca8cb4bec6abb26073f (patch)
tree9a6567736a3e64ea56dda83d39da4031bb107d16 /web-ui
parent908806ee4d2e94c691f8fb7f4ada6d45e7e9a282 (diff)
[#923] Separate out asserts into different tests
with @tayanefernandes
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/src/backup_account/page.spec.js48
-rw-r--r--web-ui/test/integration/backup_account.spec.js48
2 files changed, 72 insertions, 24 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);
+ });
});
});
});
diff --git a/web-ui/test/integration/backup_account.spec.js b/web-ui/test/integration/backup_account.spec.js
index eb247653..b44c3b2c 100644
--- a/web-ui/test/integration/backup_account.spec.js
+++ b/web-ui/test/integration/backup_account.spec.js
@@ -14,22 +14,46 @@ describe('Backup account email validation', () => {
backupAccountPage = app.find('Page');
});
- it('shows no error and enables submit button when a valid email is entered', () => {
- backupAccountPage.find('input').simulate('change', {target: {value: 'test@test.com'}});
- expect(backupAccountPage.find('InputField').props().errorText).toEqual('');
- expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(false);
+ 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);
+ });
});
- it('shows error and disables submit button on invalid email', () => {
- backupAccountPage.find('input').simulate('change', {target: {value: 'test'}});
- expect(backupAccountPage.find('InputField').props().errorText).toEqual('Please enter a valid email address');
- expect(backupAccountPage.find('SubmitButton').props().disabled).toEqual(true);
+ 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);
+ });
});
- it('shows no error and disables submit button when email is empty', () => {
- backupAccountPage.find('input').simulate('change', {target: {value: ''}});
- expect(backupAccountPage.find('InputField').props().errorText).toEqual('');
- 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);
+ });
});
});
});