summaryrefslogtreecommitdiff
path: root/web-ui/test/integration/backup_account.spec.js
blob: 2a37442ec54e4516b1862a1ea79268a5746653ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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');
    });

    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);
    });

    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('Your email is invalid');
      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);
    });
  });
});