summaryrefslogtreecommitdiff
path: root/web-ui/src/login/page.spec.js
diff options
context:
space:
mode:
authorTulio Casagrande <tuliocasagrande@gmail.com>2017-02-24 15:53:06 -0300
committerGitHub <noreply@github.com>2017-02-24 15:53:06 -0300
commitf783cbba382433c122e19a7231ebe17cc1ae7e5b (patch)
tree0f29f48029cdbc6bb53aa80ea6fa8862732b7459 /web-ui/src/login/page.spec.js
parentd77d9c41e5a5b791cf54082f0f1ae83699f0bc95 (diff)
parentef173d95b22154ee72c685cd6d5b04e9473dc988 (diff)
Merge pull request #993 from pixelated/login-errors
Login errors - some refactorings
Diffstat (limited to 'web-ui/src/login/page.spec.js')
-rw-r--r--web-ui/src/login/page.spec.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/web-ui/src/login/page.spec.js b/web-ui/src/login/page.spec.js
new file mode 100644
index 00000000..05607ecb
--- /dev/null
+++ b/web-ui/src/login/page.spec.js
@@ -0,0 +1,53 @@
+import { shallow } from 'enzyme';
+import expect from 'expect';
+import React from 'react';
+import { Page } from 'src/login/page';
+import AuthError from 'src/login/error/auth_error';
+import GenericError from 'src/login/error/generic_error';
+import Welcome from 'src/login/about/welcome';
+
+describe('Login', () => {
+ let page;
+ const mockTranslations = key => key;
+
+ it('renders login form', () => {
+ page = shallow(<Page t={mockTranslations} />);
+ expect(page.find('form').props().action).toEqual('/login');
+ });
+
+ it('renders welcome message when no error', () => {
+ page = shallow(<Page t={mockTranslations} />);
+ expect(page.find(Welcome).length).toEqual(1);
+ });
+
+ it('renders auth error message', () => {
+ page = shallow(<Page t={mockTranslations} authError />);
+ expect(page.find(AuthError).length).toEqual(1);
+ });
+
+ it('renders generic error message when error', () => {
+ page = shallow(<Page t={mockTranslations} error />);
+ expect(page.find(GenericError).length).toEqual(1);
+ });
+
+ it('does not render welcome message when error', () => {
+ page = shallow(<Page t={mockTranslations} error />);
+ expect(page.find(Welcome).length).toEqual(0);
+ });
+
+ it('does not render error message', () => {
+ page = shallow(<Page t={mockTranslations} />);
+ expect(page.find(AuthError).length).toEqual(0);
+ expect(page.find(GenericError).length).toEqual(0);
+ });
+
+ it('adds small logo class when error', () => {
+ page = shallow(<Page t={mockTranslations} error />);
+ expect(page.find('.logo').props().className).toEqual('logo small-logo');
+ });
+
+ it('does not add small logo class when no error', () => {
+ page = shallow(<Page t={mockTranslations} />);
+ expect(page.find('.logo').props().className).toEqual('logo');
+ });
+});