From 5944a63b36756e5b7ba7f8d798227683dd44cb97 Mon Sep 17 00:00:00 2001 From: Lucas Lago Date: Wed, 24 Oct 2018 22:32:13 +1100 Subject: [PATCH] test(view-component): add tests for view-component --- __tests__/tests/components/ViewContainer.js | 21 +++++++++++++++++++++ src/components/view-container.component.js | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 __tests__/tests/components/ViewContainer.js diff --git a/__tests__/tests/components/ViewContainer.js b/__tests__/tests/components/ViewContainer.js new file mode 100644 index 000000000..414705675 --- /dev/null +++ b/__tests__/tests/components/ViewContainer.js @@ -0,0 +1,21 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import { ViewContainer, StyledViewContainer } from 'components'; + +describe('', () => { + it('should always render a ', () => { + const wrapper = shallow(); + expect(wrapper.find(StyledViewContainer).length).toBe(1); + expect(wrapper.find(StyledViewContainer).prop('children')).toBe(null); + }); + + it('should pass children to if present', () => { + const wrapper = shallow(test); + expect( + wrapper + .find(StyledViewContainer) + .children() + .text() + ).toBe('test'); + }); +}); diff --git a/src/components/view-container.component.js b/src/components/view-container.component.js index 332c425d2..22f3ec40e 100644 --- a/src/components/view-container.component.js +++ b/src/components/view-container.component.js @@ -7,7 +7,7 @@ type Props = { children?: React.Element<*>, }; -const Container = styled.View` +export const StyledViewContainer = styled.View` flex: 1; flex-direction: column; justify-content: flex-start; @@ -16,7 +16,7 @@ const Container = styled.View` `; export const ViewContainer = ({ children }: Props) => ( - {children} + {children} ); ViewContainer.defaultProps = {