From 81217d68f0065f771e64ff94aef4fc76ba48002e Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 24 Aug 2020 21:38:43 -0700 Subject: [PATCH] feat #61 - Update tests --- package.json | 5 +++++ src/components/Button/Button.test.tsx | 14 ++++++++++++++ src/components/Link/Link.test.tsx | 6 ++++++ src/components/Skeleton/Skeleton.test.tsx | 15 +++++++++++++++ src/components/Skeleton/index.tsx | 2 +- 5 files changed, 41 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 36a42f84..98011794 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,11 @@ "eslintConfig": { "extends": "react-app" }, + "jest": { + "coveragePathIgnorePatterns": [ + ".stories.tsx" + ] + }, "browserslist": { "production": [ ">0.2%", diff --git a/src/components/Button/Button.test.tsx b/src/components/Button/Button.test.tsx index e5774b71..db8f2994 100644 --- a/src/components/Button/Button.test.tsx +++ b/src/components/Button/Button.test.tsx @@ -1,3 +1,4 @@ +import { Button as AntDButton } from 'antd' import React from 'react' import Button, { ButtonProps } from '.' import { shallow, ShallowWrapper } from 'enzyme' @@ -19,6 +20,19 @@ describe('Button', () => { expect(wrapper.simulate('click')) expect(mockClick).toHaveBeenCalledTimes(1) }) + + it('should pass type primary if primary is passed as true', () => { + wrapper = shallow( + + ) + expect(wrapper.find(AntDButton).props().type).toEqual('primary') + }) + + it('should have a type default by default', () => { + expect(wrapper.find(AntDButton).props().type).toEqual('default') + }) }) describe('Disabled Button', () => { diff --git a/src/components/Link/Link.test.tsx b/src/components/Link/Link.test.tsx index b2ea2514..ecf09c17 100644 --- a/src/components/Link/Link.test.tsx +++ b/src/components/Link/Link.test.tsx @@ -30,6 +30,12 @@ describe('Link with href', () => { mockProps.target ) }) + + it('has a default target of _self if none is passed in', () => { + wrapper = mount(Test) + + expect(wrapper.getDOMNode().getAttribute('target')).toBe('_self') + }) }) describe('Link', () => { diff --git a/src/components/Skeleton/Skeleton.test.tsx b/src/components/Skeleton/Skeleton.test.tsx index 3ab534da..15270415 100644 --- a/src/components/Skeleton/Skeleton.test.tsx +++ b/src/components/Skeleton/Skeleton.test.tsx @@ -41,6 +41,21 @@ describe('Skeleton', () => { } }) + describe('circle or ellipse', () => { + it('should have rounded edges', () => { + const skeleton = mount( + , + { + attachTo: document.getElementById('container') + } + ) + + const style = window.getComputedStyle(skeleton.getDOMNode()) + + expect(style.borderRadius).toEqual('50%') + }) + }) + describe('duration', () => { it('should default to 1.2 seconds if no duration is passed', () => { const skeleton = mount(, { diff --git a/src/components/Skeleton/index.tsx b/src/components/Skeleton/index.tsx index 68a3b5d5..7aadd636 100644 --- a/src/components/Skeleton/index.tsx +++ b/src/components/Skeleton/index.tsx @@ -16,7 +16,7 @@ const useStyles = createUseStyles({ backgroundRepeat: 'no-repeat', backgroundSize: '200px 100%', borderRadius: props => (props.circle ? '50%' : '4px'), - display: 'block', + display: props => (props.count > 1 ? 'block' : 'inline-block'), height: props => (props.height ? props.height : '100%'), lineHeight: 1, marginBottom: props => (props.count > 1 ? 5 : 0),