diff options
author | Thais Siqueira <thais.siqueira@gmail.com> | 2017-02-24 14:27:31 -0300 |
---|---|---|
committer | Thais Siqueira <thais.siqueira@gmail.com> | 2017-02-24 14:27:31 -0300 |
commit | fec26b211a42b068e677ac5b43080bd4bf59e47a (patch) | |
tree | e5bb685c1370e7e10cc707258fa235d953f426a3 /web-ui/src/login | |
parent | fb4630207d86d39ea05dd679b2724be87597c518 (diff) |
[#907] Moves tests to directories components
Diffstat (limited to 'web-ui/src/login')
-rw-r--r-- | web-ui/src/login/about/welcome.spec.js | 17 | ||||
-rw-r--r-- | web-ui/src/login/error/auth_error.spec.js | 17 | ||||
-rw-r--r-- | web-ui/src/login/error/generic_error.spec.js | 17 | ||||
-rw-r--r-- | web-ui/src/login/page.spec.js | 53 |
4 files changed, 104 insertions, 0 deletions
diff --git a/web-ui/src/login/about/welcome.spec.js b/web-ui/src/login/about/welcome.spec.js new file mode 100644 index 00000000..3e190c0c --- /dev/null +++ b/web-ui/src/login/about/welcome.spec.js @@ -0,0 +1,17 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import { Welcome } from 'src/login/about/welcome'; + +describe('Welcome', () => { + let welcome; + const mockTranslations = key => key; + + beforeEach(() => { + welcome = shallow(<Welcome t={mockTranslations} />); + }); + + it('renders welcome component', () => { + expect(welcome.find('.welcome').length).toEqual(1); + }); +}); diff --git a/web-ui/src/login/error/auth_error.spec.js b/web-ui/src/login/error/auth_error.spec.js new file mode 100644 index 00000000..55d8920f --- /dev/null +++ b/web-ui/src/login/error/auth_error.spec.js @@ -0,0 +1,17 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import { AuthError } from 'src/login/error/auth_error'; + +describe('AuthError', () => { + let authError; + const mockTranslations = key => key; + + beforeEach(() => { + authError = shallow(<AuthError t={mockTranslations} />); + }); + + it('renders error message', () => { + expect(authError.find('.auth-error').length).toEqual(1); + }); +}); diff --git a/web-ui/src/login/error/generic_error.spec.js b/web-ui/src/login/error/generic_error.spec.js new file mode 100644 index 00000000..1ef8349d --- /dev/null +++ b/web-ui/src/login/error/generic_error.spec.js @@ -0,0 +1,17 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import { GenericError } from 'src/login/error/generic_error'; + +describe('GenericError', () => { + let genericError; + const mockTranslations = key => key; + + beforeEach(() => { + genericError = shallow(<GenericError t={mockTranslations} />); + }); + + it('renders error message', () => { + expect(genericError.find('.generic-error').length).toEqual(1); + }); +}); diff --git a/web-ui/src/login/page.spec.js b/web-ui/src/login/page.spec.js new file mode 100644 index 00000000..0fe6f729 --- /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('Page', () => { + 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'); + }); +}); |