summaryrefslogtreecommitdiff
path: root/web-ui/src/backup_account/page.spec.js
diff options
context:
space:
mode:
authorAnike Arni <anikarni@gmail.com>2017-03-13 18:41:59 -0300
committerGitHub <noreply@github.com>2017-03-13 18:41:59 -0300
commit99a6a41ffea6de9e4b3df43265282d76c3391fd1 (patch)
tree2b4d7b3c5ebd267ad252ab05c440a90033e4f962 /web-ui/src/backup_account/page.spec.js
parent8595d3d4f31b761574c08d6f9cdf5bfc00f53a99 (diff)
parent412d95d64b5d26d4f5e00a85b7b62da23e9bb168 (diff)
Merge branch 'master' into makefile-tests
Diffstat (limited to 'web-ui/src/backup_account/page.spec.js')
-rw-r--r--web-ui/src/backup_account/page.spec.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/web-ui/src/backup_account/page.spec.js b/web-ui/src/backup_account/page.spec.js
new file mode 100644
index 00000000..334d3ba8
--- /dev/null
+++ b/web-ui/src/backup_account/page.spec.js
@@ -0,0 +1,80 @@
+import { shallow } from 'enzyme';
+import expect from 'expect';
+import React from 'react';
+import { Page } from 'src/backup_account/page';
+
+describe('BackupAccount', () => {
+ let page;
+
+ beforeEach(() => {
+ const mockTranslations = key => key;
+ page = shallow(<Page t={mockTranslations} />);
+ });
+
+ it('renders backup email page title', () => {
+ expect(page.find('h1').text()).toEqual('backup-account.title');
+ });
+
+ it('renders backup account email input field', () => {
+ expect(page.find('InputField').props().name).toEqual('email');
+ });
+
+ it('renders backup account submit button', () => {
+ expect(page.find('SubmitButton').props().buttonText).toEqual('backup-account.button');
+ });
+
+ describe('Email validation', () => {
+ let pageInstance;
+
+ beforeEach(() => {
+ pageInstance = page.instance();
+ });
+
+ it('verify initial state', () => {
+ expect(pageInstance.state.error).toEqual('');
+ 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);
+ });
+ });
+
+ 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);
+ });
+ });
+
+ 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);
+ });
+ });
+ });
+});