From 37f4317162e09a52b4c3d73a51a847917858d7f3 Mon Sep 17 00:00:00 2001 From: Marvin9 Date: Thu, 30 Apr 2020 14:31:08 +0530 Subject: [PATCH] Added unit tests --- .../defaultSearchInput.test.tsx.snap | 31 ++++++ .../Components/defaultSearchInput.test.tsx | 38 ++++++++ .../__snapshots__/defaultTag.test.tsx.snap | 94 +++++++++++++++++++ .../Components/defaultTag.test.tsx | 59 ++++++++++++ 4 files changed, 222 insertions(+) create mode 100644 src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultSearchInput/Components/__snapshots__/defaultSearchInput.test.tsx.snap create mode 100644 src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultSearchInput/Components/defaultSearchInput.test.tsx create mode 100644 src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultTag/Components/__snapshots__/defaultTag.test.tsx.snap create mode 100644 src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultTag/Components/defaultTag.test.tsx diff --git a/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultSearchInput/Components/__snapshots__/defaultSearchInput.test.tsx.snap b/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultSearchInput/Components/__snapshots__/defaultSearchInput.test.tsx.snap new file mode 100644 index 00000000..b16d64df --- /dev/null +++ b/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultSearchInput/Components/__snapshots__/defaultSearchInput.test.tsx.snap @@ -0,0 +1,31 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` should render 1`] = ` +
+ + + SearchIcon + + + + + +
+`; diff --git a/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultSearchInput/Components/defaultSearchInput.test.tsx b/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultSearchInput/Components/defaultSearchInput.test.tsx new file mode 100644 index 00000000..6a0d4250 --- /dev/null +++ b/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultSearchInput/Components/defaultSearchInput.test.tsx @@ -0,0 +1,38 @@ +import React from 'react'; +import { mount, render } from 'enzyme'; + +import { DefaultSearchInput } from './index'; +import { InputTypes } from '../types'; +import SearchIcon from '../../../ignitus-Assets/ignitus-Icons/searchIcon'; + +const props: InputTypes = { + type: 'text', + placeholder: 'Placeholder', + name: 'Input', +}; + +const input = 'input[type="text"]'; + +let wrapper; +beforeEach(() => { + wrapper = mount(); +}); + +describe('', () => { + it('should render', () => { + wrapper = render(); + expect(wrapper).toMatchSnapshot(); + }); + + it('should render input with proper props passed', () => { + const wrapperInputProps = wrapper.find(input).props(); + expect(wrapperInputProps.type).toBe(props.type); + expect(wrapperInputProps.placeholder).toBe(props.placeholder); + expect(wrapperInputProps.name).toBe(props.name); + }); + + it('should render input & SearchIcon', () => { + expect(wrapper.find('input[type="text"]').length).toBe(1); + expect(wrapper.find(SearchIcon).length).toBe(1); + }); +}); diff --git a/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultTag/Components/__snapshots__/defaultTag.test.tsx.snap b/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultTag/Components/__snapshots__/defaultTag.test.tsx.snap new file mode 100644 index 00000000..80c1c471 --- /dev/null +++ b/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultTag/Components/__snapshots__/defaultTag.test.tsx.snap @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` should render 1`] = ` +.emotion-0 { + background: #fff; + color: #000; + text-align: center; + border-radius: 2rem; + line-height: 1rem; + padding: 1rem 2rem; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-box-pack: space-around; + -webkit-justify-content: space-around; + -ms-flex-pack: space-around; + justify-content: space-around; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + margin: 0.5rem; + cursor: pointer; +} + + + Label + +`; + +exports[` should render 1`] = ` +.emotion-1 { + background: #fff; + color: #000; + text-align: center; + border-radius: 2rem; + line-height: 1rem; + padding: 1rem 2rem; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-box-pack: space-around; + -webkit-justify-content: space-around; + -ms-flex-pack: space-around; + justify-content: space-around; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + margin: 0.5rem; + cursor: pointer; +} + +.emotion-0 { + width: 1.4rem; + fill: #000; + -webkit-transition: 0.3s; + transition: 0.3s; + -webkit-flex: 1; + -ms-flex: 1; + flex: 1; + margin: 0.03rem; +} + + + + + CrossIcon + + + + + Label + +`; diff --git a/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultTag/Components/defaultTag.test.tsx b/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultTag/Components/defaultTag.test.tsx new file mode 100644 index 00000000..11d853fb --- /dev/null +++ b/src/ignitus-Shared/ignitus-DesignSystem/ignitus-Atoms/ignitus-defaultTag/Components/defaultTag.test.tsx @@ -0,0 +1,59 @@ +import React from 'react'; +import { mount, render } from 'enzyme'; +import emotionSerializer, { matchers } from 'jest-emotion'; + +import { DefaultTag1, DefaultTag2 } from './index'; +import { InputTypes } from '../types'; +import CrossIcon from '../../../ignitus-Assets/ignitus-Icons/crossIcon'; + +const props: InputTypes = { + label: 'Label', + color: '#000', + background: '#fff', +}; + +let wrapper; + +expect.addSnapshotSerializer(emotionSerializer); +expect.extend(matchers); + +const styleCheck = () => { + const span = wrapper.find('span'); + expect(span).toHaveStyleRule('color', props.color); + expect(span).toHaveStyleRule('background', props.background); +}; + +describe('', () => { + beforeEach(() => { + wrapper = mount(); + }); + + it('should render', () => { + wrapper = render(); + expect(wrapper).toMatchSnapshot(); + }); + + it('should render span tag with label', () => { + expect(wrapper.find('span').text()).toBe(props.label); + }); + + it('should render span with style passed in prop', styleCheck); +}); + +describe('', () => { + beforeEach(() => { + wrapper = mount(); + }); + + it('should render', () => { + wrapper = render(); + expect(wrapper).toMatchSnapshot(); + }); + + it('should render span tag with label & CrossIcon', () => { + expect(wrapper.find('span').length).toBe(1); + expect(wrapper.find(CrossIcon).length).toBe(1); + }); + + it('should render span with style passed in prop', styleCheck); +});