From 4e5bbf58c31d3c85c82c6d00854d2f3e82674218 Mon Sep 17 00:00:00 2001 From: Evgenij Kopitsa Date: Thu, 28 Dec 2017 21:26:58 +0300 Subject: [PATCH] Remove custom components (#48) * Remove custom components https://github.com/danilowoz/react-content-loader/issues/46 * return and in stories, update readme.md, return test for 'when type is custom' * fix indentation, move 'when type is custom' test from 'Type props are used' block --- README.md | 8 ++++---- src/custom/Circle.js | 15 --------------- src/custom/Rect.js | 17 ----------------- src/index.js | 4 ---- stories/index.js | 7 +++---- tests/custom/Circle.js | 27 --------------------------- tests/custom/Rect.js | 26 -------------------------- tests/index.js | 28 ++++++++++++++-------------- 8 files changed, 21 insertions(+), 111 deletions(-) delete mode 100644 src/custom/Circle.js delete mode 100644 src/custom/Rect.js delete mode 100644 tests/custom/Circle.js delete mode 100644 tests/custom/Rect.js diff --git a/README.md b/README.md index b3a0a57..df6fd4d 100755 --- a/README.md +++ b/README.md @@ -46,14 +46,14 @@ your custom loaders ```jsx // import the component -import ContentLoader, { Rect, Circle } from 'react-content-loader' +import ContentLoader from 'react-content-loader' const MyLoader = () => { return ( - - - + + + ) } diff --git a/src/custom/Circle.js b/src/custom/Circle.js deleted file mode 100644 index 5dcf1ca..0000000 --- a/src/custom/Circle.js +++ /dev/null @@ -1,15 +0,0 @@ -//@flow -import * as React from 'react' - -type Props = { - x: number, - y: number, - radius: number, -} - -const Circle = (props: Props): React.Element<*> => { - const { x = 0, y = 0, radius = 50 } = props - return -} - -export default Circle diff --git a/src/custom/Rect.js b/src/custom/Rect.js deleted file mode 100644 index eb53c75..0000000 --- a/src/custom/Rect.js +++ /dev/null @@ -1,17 +0,0 @@ -//@flow -import * as React from 'react' - -type Props = { - x: number, - y: number, - radius: number, - width: number, - height: number, -} - -const Rect = (props: Props): React.Element<*> => { - const { x = 0, y = 0, radius = 0, width = 50, height = 50 } = props - return -} - -export default Rect diff --git a/src/index.js b/src/index.js index 1a346f2..a08c970 100755 --- a/src/index.js +++ b/src/index.js @@ -8,9 +8,6 @@ import InstagramStyle from './stylized/InstagramStyle' import CodeStyle from './stylized/CodeStyle' import ListStyle from './stylized/ListStyle' import BulletListStyle from './stylized/BulletListStyle' -// Custom -import Rect from './custom/Rect' -import Circle from './custom/Circle' export type Props = { style: { [key: string]: any }, @@ -60,4 +57,3 @@ ContentLoader.defaultProps = { }; export default ContentLoader -export { Rect, Circle } diff --git a/stories/index.js b/stories/index.js index edec805..76f6fb8 100644 --- a/stories/index.js +++ b/stories/index.js @@ -3,7 +3,6 @@ import React from 'react' import { storiesOf } from '@storybook/react' import ContentLoader from '../src/index' -import { Rect, Circle } from '../src/index' let defaultStyle = { width: 400, @@ -16,9 +15,9 @@ const Container = props =>
{props.children}
const MyLoader = () => { return ( - - - + + + ) } diff --git a/tests/custom/Circle.js b/tests/custom/Circle.js deleted file mode 100644 index b0d5712..0000000 --- a/tests/custom/Circle.js +++ /dev/null @@ -1,27 +0,0 @@ -import React from 'react' - -import Enzyme, { mount, render } from 'enzyme' -import Adapter from 'enzyme-adapter-react-16' - -import chai, { expect } from 'chai' -import chaiEnzyme from 'chai-enzyme' -import sinon from 'sinon' - -Enzyme.configure({ adapter: new Adapter() }) -chai.use(chaiEnzyme()) - -import Circle from '../../src/custom/Circle' - -describe('', () => { - let wrapper - - beforeEach(() => { - wrapper = mount() - }) - - it('has defaults props', () => { - const props = wrapper.props() - - for (let key in props) expect(props[key]).to.not.equal(undefined) - }) -}) diff --git a/tests/custom/Rect.js b/tests/custom/Rect.js deleted file mode 100644 index 525b8c9..0000000 --- a/tests/custom/Rect.js +++ /dev/null @@ -1,26 +0,0 @@ -import React from 'react' - -import Enzyme, { mount, render } from 'enzyme' -import Adapter from 'enzyme-adapter-react-16' - -import chai, { expect } from 'chai' -import chaiEnzyme from 'chai-enzyme' -import sinon from 'sinon' - -Enzyme.configure({ adapter: new Adapter() }) -chai.use(chaiEnzyme()) -import Rect from '../../src/custom/Rect' - -describe('', () => { - let wrapper - - beforeEach(() => { - wrapper = mount() - }) - - it('has defaults props', () => { - const props = wrapper.props() - - for (let key in props) expect(props[key]).to.not.equal(undefined) - }) -}) diff --git a/tests/index.js b/tests/index.js index 1e075da..916844f 100755 --- a/tests/index.js +++ b/tests/index.js @@ -15,9 +15,6 @@ import FacebookStyle from '../src/stylized/FacebookStyle' import InstagramStyle from '../src/stylized/InstagramStyle' import CodeStyle from '../src/stylized/CodeStyle' -import Rect from '../src/custom/Rect' -import Circle from '../src/custom/Circle' - describe(':', () => { describe('Type props are used', () => { describe('when type is facebook', () => { @@ -52,18 +49,21 @@ describe(':', () => { }) }) - describe('when type is custom', () => { - const wrapper = mount( - - - - - ) + }) - it('should render custom element', () => { - expect(wrapper).to.have.descendants(Rect) - expect(wrapper).to.have.descendants(Circle) - }) + describe('when type is custom', () => { + + const wrapper = mount( + + + + + + ) + + it('should render custom element', () => { + expect(wrapper.find('rect')).to.have.length(3) + expect(wrapper.find('circle')).to.have.length(1) }) })