From e06a85b306cf35303dcbced24ffa2a8060aa4b9e Mon Sep 17 00:00:00 2001 From: Marvin Frachet Date: Sat, 27 Apr 2019 11:29:29 -0400 Subject: [PATCH] fixing tests --- .eslintrc.json | 4 ++- src/animation/fade.js | 6 +++- .../__snapshots__/imageContent.test.js.snap | 6 ++-- .../__tests__/imageContent.test.js | 2 +- src/imageContent/imageContent.js | 26 +++++++------- src/line/line.js | 12 +++---- .../__snapshots__/paragraph.spec.js.snap | 4 ++- src/paragraph/paragraph.js | 35 +++++++------------ src/placeholder/placeholder.js | 2 +- .../__tests__/placeholderStylify.test.js | 18 +++++----- src/shapes/box/__tests__/box.style.spec.js | 5 ++- src/shapes/index.js | 8 ++--- .../media/__tests__/media.style.test.js | 11 ++++-- src/shapes/stylify.js | 10 +++--- 14 files changed, 76 insertions(+), 73 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 51b78be..e2190b1 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,7 +11,9 @@ "jsx-a11y/href-no-hash": "off", "import/no-extraneous-dependencies": "off", "react/no-array-index-key": "off", - "import/no-cycle": "off" + "import/no-cycle": "off", + "import/prefer-default-export": "off", + "no-plusplus": "off" }, "env": { "jest": true diff --git a/src/animation/fade.js b/src/animation/fade.js index cee2863..47459e8 100644 --- a/src/animation/fade.js +++ b/src/animation/fade.js @@ -36,7 +36,11 @@ const Fade = ({ children, style = {}, ...props }) => { const customStyle = { opacity: animation }; - return {children}; + return ( + + {children} + + ); }; Fade.propTypes = { diff --git a/src/imageContent/__tests__/__snapshots__/imageContent.test.js.snap b/src/imageContent/__tests__/__snapshots__/imageContent.test.js.snap index 923b759..5b1e274 100644 --- a/src/imageContent/__tests__/__snapshots__/imageContent.test.js.snap +++ b/src/imageContent/__tests__/__snapshots__/imageContent.test.js.snap @@ -2,7 +2,7 @@ exports[`ImageContent should match snapshot 1`] = ` { position: 'left', size: 50, hasRadius: true, - animate: 'fade', + animation: 'fade', lineNumber: 8, textSize: 13, color: '#ff0000', diff --git a/src/imageContent/imageContent.js b/src/imageContent/imageContent.js index 271914e..bd1e8a4 100644 --- a/src/imageContent/imageContent.js +++ b/src/imageContent/imageContent.js @@ -1,7 +1,7 @@ -import React from "react"; -import PropTypes from "prop-types"; -import { Paragraph } from "../paragraph/paragraph"; -import { Media } from "../shapes"; +import React from 'react'; +import PropTypes from 'prop-types'; +import { Paragraph } from '../paragraph/paragraph'; +import { Media } from '../shapes'; export const ImageContent = ({ position, @@ -15,10 +15,8 @@ export const ImageContent = ({ firstLineWidth, ...props }) => { - const LeftComponent = () => - position === "left" ? : null; - const RightComponent = () => - position === "right" ? : null; + const LeftComponent = () => (position === 'left' ? : null); + const RightComponent = () => (position === 'right' ? : null); return ( { const height = textSize; - const alignSelf = "stretch"; + const alignSelf = 'stretch'; const backgroundColor = color; const borderRadius = textSize / 4; const marginBottom = noMargin ? 0 : textSize; @@ -21,7 +21,7 @@ export const Line = ({ backgroundColor, borderRadius, width, - marginBottom + marginBottom, }; return ; diff --git a/src/paragraph/__tests__/__snapshots__/paragraph.spec.js.snap b/src/paragraph/__tests__/__snapshots__/paragraph.spec.js.snap index d58b6a0..884dba9 100644 --- a/src/paragraph/__tests__/__snapshots__/paragraph.spec.js.snap +++ b/src/paragraph/__tests__/__snapshots__/paragraph.spec.js.snap @@ -1,7 +1,9 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Paragraph should match snapshot 1`] = ` - + - ); + lines.push(); } else if (i === lineNumber - 1) { - lines.push( - - ); + lines.push(); } else { - lines.push( - - ); + lines.push(); } } @@ -49,13 +38,13 @@ Paragraph.propTypes = { color: PropTypes.string, width: PropTypes.string, lastLineWidth: PropTypes.string, - firstLineWidth: PropTypes.string + firstLineWidth: PropTypes.string, }; Paragraph.defaultProps = { textSize: 12, - color: "#efefef", - width: "100%", - lastLineWidth: "100%", - firstLineWidth: "100%" + color: '#efefef', + width: '100%', + lastLineWidth: '100%', + firstLineWidth: '100%', }; diff --git a/src/placeholder/placeholder.js b/src/placeholder/placeholder.js index b0996b0..c5ab4a8 100644 --- a/src/placeholder/placeholder.js +++ b/src/placeholder/placeholder.js @@ -24,7 +24,7 @@ const makeRoot = (animation) => { const Animation = Animations[animation]; if (!Animation) { - throw new Error(`Animation "${animation}" doesn\'t exist in the library`); + throw new Error(`Animation "${animation}" doesn't exist in the library`); } return Animation; diff --git a/src/shapes/__tests__/placeholderStylify.test.js b/src/shapes/__tests__/placeholderStylify.test.js index c5c327b..df3887f 100644 --- a/src/shapes/__tests__/placeholderStylify.test.js +++ b/src/shapes/__tests__/placeholderStylify.test.js @@ -1,24 +1,24 @@ -import React from "react"; -import { View } from "react-native"; -import { shallow } from "enzyme"; -import { stylify } from "../stylify"; +import React from 'react'; +import { View } from 'react-native'; +import { shallow } from 'enzyme'; +import { stylify } from '../stylify'; -describe("stylify", () => { +describe('stylify', () => { let computeStyle; let Component; beforeEach(() => { - computeStyle = () => ({ backgroundColor: "red" }); + computeStyle = () => ({ backgroundColor: 'red' }); Component = props => ; }); - it("should inject the passed style merged with the computed ones", () => { + it('should inject the passed style merged with the computed ones', () => { const StyledComponent = stylify(computeStyle)(Component); const wrapper = shallow(); - expect(wrapper.find(Component).prop("style")).toEqual({ + expect(wrapper.find(Component).prop('style')).toEqual({ marginLeft: 100, - backgroundColor: "red" + backgroundColor: 'red', }); }); }); diff --git a/src/shapes/box/__tests__/box.style.spec.js b/src/shapes/box/__tests__/box.style.spec.js index 3ee4931..7f4dc2b 100644 --- a/src/shapes/box/__tests__/box.style.spec.js +++ b/src/shapes/box/__tests__/box.style.spec.js @@ -13,7 +13,10 @@ describe('computeStyleBox', () => { it('should have retrieved the computed styles', () => { const styles = computeStyleBox({ - height: 1000, width: 1000, radius: 10, color: 'blue', + height: 1000, + width: 1000, + radius: 10, + color: 'blue', }); expect(styles).toEqual({ height: 1000, diff --git a/src/shapes/index.js b/src/shapes/index.js index a4e11d2..4f3e9bb 100644 --- a/src/shapes/index.js +++ b/src/shapes/index.js @@ -1,7 +1,7 @@ -import { View } from "react-native"; -import { stylify } from "./stylify"; -import computeStyleMedia from "./media/media.style"; -import computeStyleBox from "./box/box.style"; +import { View } from 'react-native'; +import { stylify } from './stylify'; +import computeStyleMedia from './media/media.style'; +import computeStyleBox from './box/box.style'; export const Media = stylify(computeStyleMedia)(View); export const Box = stylify(computeStyleBox)(View); diff --git a/src/shapes/media/__tests__/media.style.test.js b/src/shapes/media/__tests__/media.style.test.js index fc55966..e0213e4 100644 --- a/src/shapes/media/__tests__/media.style.test.js +++ b/src/shapes/media/__tests__/media.style.test.js @@ -9,9 +9,14 @@ describe('MediaStyle', () => { borderRadius: 40, backgroundColor: 'blue', }; - expect(mediaStyle({ - size: 80, color: 'blue', width: '100%', hasRadius: true, - })).toEqual(style); + expect( + mediaStyle({ + size: 80, + color: 'blue', + width: '100%', + hasRadius: true, + }), + ).toEqual(style); }); it('should provide a style object that respects the constraints and parameters', () => { diff --git a/src/shapes/stylify.js b/src/shapes/stylify.js index 10dea0c..9cb163b 100644 --- a/src/shapes/stylify.js +++ b/src/shapes/stylify.js @@ -1,18 +1,18 @@ -import React from "react"; -import PropTypes from "prop-types"; +import React from 'react'; +import PropTypes from 'prop-types'; -export const stylify = computeStyles => Component => { +export const stylify = computeStyles => (Component) => { const StyledComponent = ({ style, ...otherProps }) => { const styles = { ...computeStyles(otherProps), ...style }; return ; }; StyledComponent.propTypes = { - style: PropTypes.shape({}) + style: PropTypes.shape({}), }; StyledComponent.defaultProps = { - style: {} + style: {}, }; return StyledComponent;