diff options
Diffstat (limited to 'web-ui/test/unit')
-rw-r--r-- | web-ui/test/unit/login/app.spec.js | 20 | ||||
-rw-r--r-- | web-ui/test/unit/login/error/auth_error.spec.js | 17 | ||||
-rw-r--r-- | web-ui/test/unit/login/error/generic_error.spec.js | 17 | ||||
-rw-r--r-- | web-ui/test/unit/util.spec.js | 4 |
4 files changed, 49 insertions, 9 deletions
diff --git a/web-ui/test/unit/login/app.spec.js b/web-ui/test/unit/login/app.spec.js index 347e2b19..c1d63235 100644 --- a/web-ui/test/unit/login/app.spec.js +++ b/web-ui/test/unit/login/app.spec.js @@ -2,25 +2,31 @@ import { shallow } from 'enzyme'; import expect from 'expect'; import React from 'react'; import { App } from 'src/login/app'; +import AuthError from 'src/login/error/auth_error'; +import GenericError from 'src/login/error/generic_error'; describe('App', () => { let app; const mockTranslations = key => key; - beforeEach(() => { - app = shallow(<App t={mockTranslations} />); - }); - it('renders login form', () => { + app = shallow(<App t={mockTranslations} />); expect(app.find('form').props().action).toEqual('/login'); }); it('renders auth error message', () => { app = shallow(<App t={mockTranslations} authError />); - expect(app.find('.error').length).toEqual(1); + expect(app.find(AuthError).length).toEqual(1); }); - it('does not render auth error message', () => { - expect(app.find('.error').length).toEqual(0); + it('renders generic error message', () => { + app = shallow(<App t={mockTranslations} error />); + expect(app.find(GenericError).length).toEqual(1); + }); + + it('does not render error message', () => { + app = shallow(<App t={mockTranslations} />); + expect(app.find(AuthError).length).toEqual(0); + expect(app.find(GenericError).length).toEqual(0); }); }); diff --git a/web-ui/test/unit/login/error/auth_error.spec.js b/web-ui/test/unit/login/error/auth_error.spec.js new file mode 100644 index 00000000..55d8920f --- /dev/null +++ b/web-ui/test/unit/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/test/unit/login/error/generic_error.spec.js b/web-ui/test/unit/login/error/generic_error.spec.js new file mode 100644 index 00000000..1ef8349d --- /dev/null +++ b/web-ui/test/unit/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/test/unit/util.spec.js b/web-ui/test/unit/util.spec.js index 84decf6f..968b2d83 100644 --- a/web-ui/test/unit/util.spec.js +++ b/web-ui/test/unit/util.spec.js @@ -5,12 +5,12 @@ describe('Utils', () => { describe('.hasQueryParameter', () => { global.window = { location: { - search: '?auth&lng=pt-BR' + search: '?auth-error&lng=pt-BR' } }; it('checks if param included in query parameters', () => { - expect(Util.hasQueryParameter('auth')).toBe(true); + expect(Util.hasQueryParameter('auth-error')).toBe(true); }); it('checks if param not included in query parameters', () => { |