Skip to content

Commit

Permalink
feat #61 - Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Aug 25, 2020
1 parent 5f9ae69 commit 81217d6
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
"eslintConfig": {
"extends": "react-app"
},
"jest": {
"coveragePathIgnorePatterns": [
".stories.tsx"
]
},
"browserslist": {
"production": [
">0.2%",
Expand Down
14 changes: 14 additions & 0 deletions src/components/Button/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Button as AntDButton } from 'antd'
import React from 'react'
import Button, { ButtonProps } from '.'
import { shallow, ShallowWrapper } from 'enzyme'
Expand All @@ -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(
<Button onClick={mockClick} primary>
Test
</Button>
)
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', () => {
Expand Down
6 changes: 6 additions & 0 deletions src/components/Link/Link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ describe('Link with href', () => {
mockProps.target
)
})

it('has a default target of _self if none is passed in', () => {
wrapper = mount(<Link onClick={mockClick}>Test</Link>)

expect(wrapper.getDOMNode().getAttribute('target')).toBe('_self')
})
})

describe('Link', () => {
Expand Down
15 changes: 15 additions & 0 deletions src/components/Skeleton/Skeleton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ describe('Skeleton', () => {
}
})

describe('circle or ellipse', () => {
it('should have rounded edges', () => {
const skeleton = mount(
<Skeleton circle height={100} width={80} />,
{
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(<Skeleton />, {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Skeleton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 81217d6

Please sign in to comment.