summaryrefslogtreecommitdiff
path: root/web-ui/test
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/test')
-rw-r--r--web-ui/test/integration/backup_account.spec.js59
-rw-r--r--web-ui/test/integration/i18n.js14
-rw-r--r--web-ui/test/integration/setup.js15
-rw-r--r--web-ui/test/integration/translations.spec.js23
-rw-r--r--web-ui/test/jasmine.json9
-rw-r--r--web-ui/test/spec/account_recovery/page.spec.js12
-rw-r--r--web-ui/test/test-main.js2
7 files changed, 112 insertions, 22 deletions
diff --git a/web-ui/test/integration/backup_account.spec.js b/web-ui/test/integration/backup_account.spec.js
new file mode 100644
index 00000000..b44c3b2c
--- /dev/null
+++ b/web-ui/test/integration/backup_account.spec.js
@@ -0,0 +1,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').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').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').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);
+ });
+ });
+ });
+});
diff --git a/web-ui/test/integration/i18n.js b/web-ui/test/integration/i18n.js
new file mode 100644
index 00000000..099df2d7
--- /dev/null
+++ b/web-ui/test/integration/i18n.js
@@ -0,0 +1,14 @@
+import i18n from 'i18next';
+import translations from '../../app/locales/en_US/translation.json';
+
+i18n
+ .init({
+ lng: 'en',
+ resources: {
+ en: {
+ translation: translations
+ }
+ }
+ });
+
+export default i18n;
diff --git a/web-ui/test/integration/setup.js b/web-ui/test/integration/setup.js
new file mode 100644
index 00000000..49cd381e
--- /dev/null
+++ b/web-ui/test/integration/setup.js
@@ -0,0 +1,15 @@
+// Enzyme setup file
+// https://github.com/airbnb/enzyme/blob/master/docs/guides/jsdom.md
+var jsdom = require('jsdom').jsdom;
+
+global.document = jsdom('');
+global.window = document.defaultView;
+Object.keys(document.defaultView).forEach((property) => {
+ if (typeof global[property] === 'undefined') {
+ global[property] = document.defaultView[property];
+ }
+});
+
+global.navigator = {
+ userAgent: 'node.js'
+};
diff --git a/web-ui/test/integration/translations.spec.js b/web-ui/test/integration/translations.spec.js
new file mode 100644
index 00000000..fe17838b
--- /dev/null
+++ b/web-ui/test/integration/translations.spec.js
@@ -0,0 +1,23 @@
+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 LoginPage from 'src/login/page';
+import testI18n from './i18n';
+
+describe('Translations', () => {
+ context('Backup Account Page', () => {
+ it('translates all key', () => {
+ const app = mount(<App i18n={testI18n} child={<BackupAccountPage />} />);
+ expect(app.text()).toNotContain('untranslated', 'Unstranslated message found in the text: ' + app.text());
+ });
+ });
+
+ context('Login Page', () => {
+ it('translates all key', () => {
+ const app = mount(<App i18n={testI18n} child={<LoginPage />} />);
+ expect(app.text()).toNotContain('untranslated', 'Unstranslated message found in the text: ' + app.text());
+ });
+ });
+});
diff --git a/web-ui/test/jasmine.json b/web-ui/test/jasmine.json
deleted file mode 100644
index 969304b6..00000000
--- a/web-ui/test/jasmine.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "spec_dir": "test/spec/account_recovery/",
- "spec_files": [
- "**/*[sS]pec.js"
- ],
- "helpers": [
- "helpers/**/*.js"
- ]
-}
diff --git a/web-ui/test/spec/account_recovery/page.spec.js b/web-ui/test/spec/account_recovery/page.spec.js
deleted file mode 100644
index f550a51e..00000000
--- a/web-ui/test/spec/account_recovery/page.spec.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import {shallow} from 'enzyme'
-import expect from 'expect'
-import React from 'react'
-import Page from '../../../app/js/account_recovery/page'
-
-describe('Page', () => {
- 'use strict';
- it('renders backup email page title', () => {
- const page = shallow(<Page />);
- expect(page.find('h1').text()).toEqual('E se vocĂȘ esquecer sua senha?');
- });
-});
diff --git a/web-ui/test/test-main.js b/web-ui/test/test-main.js
index b7dc430f..4396993f 100644
--- a/web-ui/test/test-main.js
+++ b/web-ui/test/test-main.js
@@ -1,7 +1,7 @@
var tests = Object.keys(window.__karma__.files).filter(function (file) {
'use strict';
- return !(/account_recovery/.test(file)) && (/\.spec\.js$/.test(file));
+ return (/\.spec\.js$/.test(file));
});
beforeEach(function() {