Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat #61 - Skeleton loader component #66

Merged
merged 3 commits into from
Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 25 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-jss": "^10.4.0",
"react-loading-skeleton": "^2.1.1",
"react-scripts": "^3.4.3",
"typescript": "^3.9.7"
},
Expand All @@ -42,6 +41,11 @@
"eslintConfig": {
"extends": "react-app"
},
"jest": {
"coveragePathIgnorePatterns": [
".stories.tsx"
]
},
"browserslist": {
"production": [
">0.2%",
Expand Down
80 changes: 56 additions & 24 deletions src/__snapshots__/storybook.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ exports[`Storyshots InputField Default 1`] = `

exports[`Storyshots InputField Error 1`] = `
<div
className="container-0-2-2 container-d4-0-2-11"
className="container-0-2-2 container-d4-0-2-14"
>
<div
className="label-0-2-5"
Expand All @@ -149,7 +149,7 @@ exports[`Storyshots InputField Error 1`] = `

exports[`Storyshots InputField Full Width 1`] = `
<div
className="container-0-2-2 container-d3-0-2-10"
className="container-0-2-2 container-d3-0-2-13"
>
<div
className="label-0-2-5"
Expand Down Expand Up @@ -177,33 +177,19 @@ exports[`Storyshots InputField Loading 1`] = `
<div
className="label-0-2-5"
>
<span>
<span
className="react-loading-skeleton css-1vmnjpn-skeletonStyles-Skeleton"
style={
Object {
"width": 100,
}
}
>
</span>
<span
className="container-0-2-10 container-d0-0-2-11"
>

</span>
</div>
<div
className="input-0-2-4"
>
<span>
<span
className="react-loading-skeleton css-1vmnjpn-skeletonStyles-Skeleton"
style={
Object {
"height": 13,
}
}
>
</span>
<span
className="container-0-2-10 container-d1-0-2-12"
>

</span>
</div>
</div>
Expand Down Expand Up @@ -243,6 +229,52 @@ exports[`Storyshots Link Href 1`] = `
</a>
`;

exports[`Storyshots Skeleton Circle 1`] = `
<span
className="container-0-2-10 container-d3-0-2-16"
>

</span>
`;

exports[`Storyshots Skeleton Count 1`] = `
Array [
<span
className="container-0-2-10 container-d4-0-2-17"
>

</span>,
<span
className="container-0-2-10 container-d4-0-2-17"
>

</span>,
<span
className="container-0-2-10 container-d4-0-2-17"
>

</span>,
<span
className="container-0-2-10 container-d4-0-2-17"
>

</span>,
<span
className="container-0-2-10 container-d4-0-2-17"
>

</span>,
]
`;

exports[`Storyshots Skeleton Default 1`] = `
<span
className="container-0-2-10 container-d2-0-2-15"
>

</span>
`;

exports[`Storyshots Tag Colored 1`] = `
<span
className="ant-tag ant-tag-has-color"
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/Icon/Icon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ describe('Predefined Icon', () => {
it('has the correct height', () => {
expect(wrapper.getDOMNode().getAttribute('height')).toBe('64')
})

it('renders with a default height of 32', () => {
wrapper = mount(<Icon iconKey='dassana-blue' />)

expect(wrapper.getDOMNode().getAttribute('height')).toBe('32')
})
})

describe('Custom Icon', () => {
Expand Down
12 changes: 3 additions & 9 deletions src/components/InputField/InputField.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Input } from 'antd'
import React from 'react'
import Skeleton from 'react-loading-skeleton'
import Skeleton from '../Skeleton'
import InputField, { InputFieldProps } from './index'
import { mount, ReactWrapper, shallow } from 'enzyme'

Expand Down Expand Up @@ -98,10 +98,7 @@ describe('InputField', () => {
attachTo: document.getElementById('container')
})

const element = document.getElementsByClassName(
wrapper.getDOMNode().className
)[0]
const style = window.getComputedStyle(element)
const style = window.getComputedStyle(wrapper.getDOMNode())

expect(style.width).toEqual('100%')
})
Expand All @@ -111,10 +108,7 @@ describe('InputField', () => {
attachTo: document.getElementById('container')
})

const element = document.getElementsByClassName(
wrapper.getDOMNode().className
)[0]
const style = window.getComputedStyle(element)
const style = window.getComputedStyle(wrapper.getDOMNode())

expect(style.width).not.toEqual('100%')
})
Expand Down
6 changes: 3 additions & 3 deletions src/components/InputField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'antd/lib/input/style/index.css'
import cn from 'classnames'
import { createUseStyles } from 'react-jss'
import { Input } from 'antd'
import Skeleton from 'react-loading-skeleton'
import Skeleton from '../Skeleton'
import React, { FC } from 'react'

const useStyles = createUseStyles({
Expand Down Expand Up @@ -61,12 +61,12 @@ const InputFieldSkeleton: FC<InputFieldProps> = (props: InputFieldProps) => {

export interface InputFieldProps {
/**
* Array of classes to pass to button.
* Array of classes to pass to input
* @default []
*/
classes?: string[]
/**
* Adds the disabled attribute and styles (opacity, gray scale filter, no pointer events).
* Adds the disabled attribute and styles (opacity, gray scale filter, no pointer events)
* @default false
*/
disabled?: boolean
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
Loading