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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
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');
});
context('with valid email', () => {
beforeEach(() => {
backupAccountPage.find('input[name="email"]').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);
});
});
context('with invalid email', () => {
beforeEach(() => {
backupAccountPage.find('input[name="email"]').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);
});
});
context('with empty email', () => {
beforeEach(() => {
backupAccountPage.find('input[name="email"]').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);
});
});
});
});
|