diff options
Diffstat (limited to 'web-ui/src/common')
-rw-r--r-- | web-ui/src/common/footer/footer.spec.js | 17 | ||||
-rw-r--r-- | web-ui/src/common/header/header.spec.js | 17 | ||||
-rw-r--r-- | web-ui/src/common/input_field/input_field.spec.js | 20 | ||||
-rw-r--r-- | web-ui/src/common/submit_button/submit_button.spec.js | 16 | ||||
-rw-r--r-- | web-ui/src/common/util.spec.js | 20 |
5 files changed, 90 insertions, 0 deletions
diff --git a/web-ui/src/common/footer/footer.spec.js b/web-ui/src/common/footer/footer.spec.js new file mode 100644 index 00000000..f1247233 --- /dev/null +++ b/web-ui/src/common/footer/footer.spec.js @@ -0,0 +1,17 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import { Footer } from 'src/common/footer/footer'; + +describe('Footer', () => { + let footer; + + beforeEach(() => { + const mockTranslations = key => key; + footer = shallow(<Footer t={mockTranslations} />); + }); + + it('renders the footer content', () => { + expect(footer.find('footer').text()).toContain('footer-text'); + }); +}); diff --git a/web-ui/src/common/header/header.spec.js b/web-ui/src/common/header/header.spec.js new file mode 100644 index 00000000..82e29e1c --- /dev/null +++ b/web-ui/src/common/header/header.spec.js @@ -0,0 +1,17 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import { Header } from 'src/common/header/header'; + +describe('Header', () => { + let header; + + beforeEach(() => { + const mockTranslations = key => key; + header = shallow(<Header t={mockTranslations} />); + }); + + it('renders the header content', () => { + expect(header.find('header').text()).toContain('logout'); + }); +}); diff --git a/web-ui/src/common/input_field/input_field.spec.js b/web-ui/src/common/input_field/input_field.spec.js new file mode 100644 index 00000000..0c044ce1 --- /dev/null +++ b/web-ui/src/common/input_field/input_field.spec.js @@ -0,0 +1,20 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import InputField from 'src/common/input_field/input_field'; + +describe('InputField', () => { + let inputField; + + beforeEach(() => { + inputField = shallow(<InputField label='Email' name='email' />); + }); + + it('renders an input of type text for email', () => { + expect(inputField.find('input[type="text"]').props().name).toEqual('email'); + }); + + it('renders a label for the email', () => { + expect(inputField.find('label').text()).toEqual('Email'); + }); +}); diff --git a/web-ui/src/common/submit_button/submit_button.spec.js b/web-ui/src/common/submit_button/submit_button.spec.js new file mode 100644 index 00000000..8279547c --- /dev/null +++ b/web-ui/src/common/submit_button/submit_button.spec.js @@ -0,0 +1,16 @@ +import { shallow } from 'enzyme'; +import expect from 'expect'; +import React from 'react'; +import SubmitButton from 'src/common/submit_button/submit_button'; + +describe('SubmitButton', () => { + let submitButton; + + beforeEach(() => { + submitButton = shallow(<SubmitButton buttonText='Add Email' />); + }); + + it('renders an input of type submit for add email', () => { + expect(submitButton.find('input[type="submit"]').props().value).toEqual('Add Email'); + }); +}); diff --git a/web-ui/src/common/util.spec.js b/web-ui/src/common/util.spec.js new file mode 100644 index 00000000..805d9dd5 --- /dev/null +++ b/web-ui/src/common/util.spec.js @@ -0,0 +1,20 @@ +import expect from 'expect'; +import Util from 'src/common/util'; + +describe('Utils', () => { + describe('.hasQueryParameter', () => { + global.window = { + location: { + search: '?auth-error&lng=pt-BR' + } + }; + + it('checks if param included in query parameters', () => { + expect(Util.hasQueryParameter('auth-error')).toBe(true); + }); + + it('checks if param not included in query parameters', () => { + expect(Util.hasQueryParameter('error')).toBe(false); + }); + }); +}); |