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

Update tests #227

Merged
merged 29 commits into from
Aug 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
22080d4
update Flash tests
Aug 22, 2018
008cde4
remove flexAuto test
Aug 22, 2018
a69539f
remove todo from flash
Aug 22, 2018
59c082b
update margin and padding tests for FlexItem
Aug 22, 2018
753f35f
update FlexItem snap
Aug 22, 2018
781572b
update Heading tests & snaps
Aug 22, 2018
42687c8
Creating UtilitySystemProps test to test all components for space and…
jonrohan Aug 24, 2018
78ca5a4
remove old tests
Aug 24, 2018
fa86f94
fix heading test
Aug 24, 2018
f027def
set up required props in UtilitySystemProps
Aug 24, 2018
9335e55
fix missing prop error message for OcticonButton
Aug 24, 2018
f83b1a2
update octicon button snap
Aug 24, 2018
966a10e
fix BorderBox lint issues
Aug 24, 2018
327e67f
fix BranchName lint erros
Aug 24, 2018
3ef7fa5
re-enable BranchName system component test
Aug 24, 2018
5e65449
fix Button lint errors
Aug 24, 2018
7dbebd1
reenable CircleBadge system test
Aug 24, 2018
e3b43bf
fix CircleOcticon lint issues
Aug 24, 2018
7223911
re-enable system component test in CounterLabel
Aug 24, 2018
5fb9195
fix auto-fixable lint errors
Aug 24, 2018
08e2561
fix FlexItem lint errors
Aug 24, 2018
52baa4d
fix Heading lint errors
Aug 24, 2018
cf6cd94
fix Link lint errors
Aug 24, 2018
f748ed6
fix Text lint errors
Aug 24, 2018
95f3fd8
fix UtilitySystemProps lint errors
Aug 24, 2018
fa550eb
re-enable system component test for DonutChart
Aug 24, 2018
3ec7957
Merge branch 'release-2.0.1-beta' of github.com:primer/primer-react i…
Aug 24, 2018
b9f133f
one last linting error
Aug 24, 2018
ef208f4
undo lint fixes
Aug 25, 2018
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
5 changes: 4 additions & 1 deletion examples/component-examples/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default {
<Box pb={4}>color</Box>
</th>
<th colSpan={textColors.length}>
<Mono pb={4}>bg={`{color}`}</Mono>
<Mono pb={4}>
bg=
{`{color}`}
</Mono>
</th>
<th>
<Mono pb={4}>borderColor</Mono>
Expand Down
24 changes: 2 additions & 22 deletions src/__tests__/BorderBox.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import theme, {colors} from '../theme'
import {colors} from '../theme'
import BorderBox from '../BorderBox'
import Box from '../Box'
import {px, render, renderStyles} from '../utils/testing'
import {render} from '../utils/testing'

describe('BorderBox', () => {
it('is a system component', () => {
Expand All @@ -13,26 +13,6 @@ describe('BorderBox', () => {
expect(render(<BorderBox />)).toEqual(render(<Box {...BorderBox.defaultProps} />))
})

it('renders margin', () => {
expect(render(<BorderBox m={1} />)).toHaveStyleRule('margin', px(theme.space[1]))
expect(renderStyles(<BorderBox m={[0, 1]} />)).toMatchKeys({
margin: px(theme.space[0]),
[`@media screen and (min-width:${px(theme.breakpoints[0])})`]: {
margin: px(theme.space[1])
}
})
})

it('renders padding', () => {
expect(render(<BorderBox p={1} />)).toHaveStyleRule('padding', px(theme.space[1]))
expect(renderStyles(<BorderBox p={[0, 1]} />)).toMatchKeys({
padding: px(theme.space[0]),
[`@media screen and (min-width:${px(theme.breakpoints[0])})`]: {
padding: px(theme.space[1])
}
})
})

it('renders borders', () => {
expect(render(<BorderBox borderColor="green.5" />)).toHaveStyleRule('border-color', colors.green[5])
expect(render(<BorderBox borderBottom={0} />)).toHaveStyleRule('border-bottom', '0')
Expand Down
8 changes: 0 additions & 8 deletions src/__tests__/Box.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,6 @@ describe('Box', () => {
expect(render(<Box position="relative" />)).toMatchSnapshot()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we haven't touched this, but I would expect this snapshot to look like <div position="relative"> since we moved the position props in #202. This test should go away.

})

it('respects bg', () => {
expect(render(<Box bg="yellow.2" theme={theme} />)).toMatchSnapshot()
})

it('respects color', () => {
expect(render(<Box color="red.5" theme={theme} />)).toMatchSnapshot()
})

it('renders shadow', () => {
expect(render(<Box boxShadow="small" theme={theme} />)).toMatchSnapshot()
expect(render(<Box boxShadow="medium" theme={theme} />)).toMatchSnapshot()
Expand Down
11 changes: 2 additions & 9 deletions src/__tests__/BranchName.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import BranchName from '../BranchName'
import {render, rendersClass} from '../utils/testing'
import {render} from '../utils/testing'
import {COMMON} from '../system-props'

describe('BranchName', () => {
xit('is a system component', () => {
it('is a system component', () => {
expect(BranchName.systemComponent).toEqual(true)
})

Expand All @@ -24,13 +24,6 @@ describe('BranchName', () => {
expect(render(<BranchName is="span" href="#" />).props.href).toEqual(null)
})

xit('respects margin utility prop', () => {
expect(rendersClass(<BranchName m={1} />, 'm-1')).toEqual(true)
})

xit('respects padding utility prop', () => {
expect(rendersClass(<BranchName p={1} />, 'p-1')).toEqual(true)
})
it('implements common system props', () => {
expect(BranchName).toImplementSystemProps(COMMON)
})
Expand Down
19 changes: 1 addition & 18 deletions src/__tests__/Button.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react'
import {Button, ButtonPrimary, ButtonDanger, ButtonLink, ButtonOutline} from '..'
import theme from '../theme'
import {render} from '../utils/testing'
import {COMMON} from '../system-props'

function noop() {}

describe('Button', () => {
xit('is a system component', () => {
it('is a system component', () => {
expect(Button.systemComponent).toEqual(true)
})

Expand Down Expand Up @@ -75,10 +74,6 @@ describe('ButtonPrimary', () => {
expect(render(<ButtonPrimary />).type).toEqual('button')
expect(render(<ButtonPrimary />).props.className).toContain('btn-primary')
})

it('implements common system props', () => {
expect(render(<ButtonPrimary m={2} theme={theme} />)).toHaveStyleRule('margin', '8px')
})
})

describe('ButtonDanger', () => {
Expand All @@ -87,10 +82,6 @@ describe('ButtonDanger', () => {
expect(render(<ButtonDanger />).props.className).toContain('btn-danger')
})

it('implements common system props', () => {
expect(render(<ButtonDanger m={2} theme={theme} />)).toHaveStyleRule('margin', '8px')
})

xit('renders children', () => {
expect(
render(
Expand All @@ -113,19 +104,11 @@ describe('ButtonLink', () => {
expect(render(<ButtonLink />).type).toEqual('button')
expect(render(<ButtonLink />).props.className).toContain('btn-link')
})

it('implements common system props', () => {
expect(render(<ButtonLink m={2} theme={theme} />)).toHaveStyleRule('margin', '8px')
})
})

describe('ButtonOutline', () => {
it('renders a <button> by default', () => {
expect(render(<ButtonOutline />).type).toEqual('button')
expect(render(<ButtonOutline />).props.className).toContain('btn-outline')
})

it('implements common system props', () => {
expect(render(<ButtonOutline m={2} theme={theme} />)).toHaveStyleRule('margin', '8px')
})
})
2 changes: 1 addition & 1 deletion src/__tests__/CircleBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {render, mount} from '../utils/testing'
const imgInput = <img alt="" src="primer.jpg" />

describe('CircleBadge', () => {
xit('is a system component', () => {
it('is a system component', () => {
expect(CircleBadge.systemComponent).toEqual(true)
})

Expand Down
10 changes: 1 addition & 9 deletions src/__tests__/CircleOcticon.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import {Check} from '@githubprimer/octicons-react'
import theme, {colors} from '../theme'
import {colors} from '../theme'
import CircleOcticon from '../CircleOcticon'
import {render} from '../utils/testing'

Expand Down Expand Up @@ -28,12 +28,4 @@ describe('CircleOcticon', () => {
expect(result).toHaveStyleRule('width', '32px')
expect(result).toHaveStyleRule('height', '32px')
})

it('respects margin utility prop', () => {
expect(render(<CircleOcticon icon={Check} m={4} />)).toHaveStyleRule('margin', `${theme.space[4]}px`)
})

it('respects padding utility prop', () => {
expect(render(<CircleOcticon icon={Check} p={4} />)).toHaveStyleRule('padding', `${theme.space[4]}px`)
})
})
2 changes: 1 addition & 1 deletion src/__tests__/CounterLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {render} from '../utils/testing'
import {COMMON} from '../system-props'

describe('CounterLabel', () => {
xit('is a system component', () => {
it('is a system component', () => {
expect(CounterLabel.systemComponent).toEqual(true)
})

Expand Down
14 changes: 4 additions & 10 deletions src/__tests__/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ describe('Details', () => {
expect(render(<Details />)).toHaveClass('details-reset')
})

it('respects margin utility prop', () => {
expect(render(<Details m={1} />)).toHaveStyleRule('margin', '4px')
})

it('respects padding utility prop', () => {
expect(render(<Details p={1} />)).toHaveStyleRule('padding', '4px')
})

it('Respects the open prop', () => {
expect(mount(<Details open />).props().open).toEqual(true)
})
Expand All @@ -35,13 +27,15 @@ describe('Details', () => {
expect(
render(
<Details>
<summary>hi</summary>bye
<summary>hi</summary>
bye
</Details>
)
).toEqual(
render(
<details open={false} className="details-reset">
<summary>hi</summary>bye
<summary>hi</summary>
bye
</details>
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/DonutChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import theme, {colors} from '../theme'
import {render} from '../utils/testing'

describe('DonutChart', () => {
xit('is a system component', () => {
it('is a system component', () => {
expect(DonutChart.systemComponent).toEqual(true)
})

Expand Down
8 changes: 0 additions & 8 deletions src/__tests__/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,4 @@ describe('Dropdown', () => {
expect(rendered.type).toEqual('div')
expect(rendered.props.className).toContain('BtnGroup')
})

it('respects margin utility prop', () => {
expect(render(<Dropdown m={1} />)).toHaveStyleRule('margin', '4px')
})

it('respects padding utility prop', () => {
expect(render(<Dropdown p={1} />)).toHaveStyleRule('padding', '4px')
})
})
11 changes: 0 additions & 11 deletions src/__tests__/Flash.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import Flash from '../Flash'
import theme from '../theme'
import {COMMON} from '../system-props'
import {render} from '../utils/testing'

Expand Down Expand Up @@ -28,14 +27,4 @@ describe('Flash', () => {
expect(render(<Flash scheme="red" />)).toHaveClasses(['flash', 'flash-error'])
expect(render(<Flash scheme="green" />)).toHaveClasses(['flash', 'flash-success'])
})

// TODO: understand why these aren't working

xit('respects margin utility prop', () => {
expect(render(<Flash m={1} theme={theme} />)).toHaveStyleRule('margin', '4px')
})

xit('respects padding utility prop', () => {
expect(render(<Flash p={2} theme={theme} />)).toHaveStyleRule('padding', '8px')
})
})
13 changes: 0 additions & 13 deletions src/__tests__/FlexItem.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import FlexItem from '../FlexItem'
import {FLEX_ITEM} from '../system-props'
import theme from '../theme'
import {render} from '../utils/testing'

describe('FlexItem', () => {
Expand All @@ -17,10 +16,6 @@ describe('FlexItem', () => {
expect(render(<FlexItem alignSelf="center" />)).toMatchSnapshot()
})

xit('respects flexAuto', () => {
expect(render(<FlexItem flexAuto />)).toMatchSnapshot()
})

it('renders as correct tag', () => {
const item = render(
<FlexItem is="button" alignSelf="center">
Expand All @@ -30,12 +25,4 @@ describe('FlexItem', () => {
expect(item.type).toEqual('button')
expect(item).toMatchSnapshot()
})

xit('margin utility', () => {
expect(render(<FlexItem m={2} them={theme} />)).toMatchSnapshot()
})

xit('padding utility', () => {
expect(render(<FlexItem p={1} them={theme} />)).toMatchSnapshot()
})
})
17 changes: 1 addition & 16 deletions src/__tests__/Heading.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable jsx-a11y/heading-has-content */
import React from 'react'
import Heading from '../Heading'
import {Heading} from '..'
import {render} from '../utils/testing'

const theme = {
Expand Down Expand Up @@ -32,21 +32,6 @@ describe('Heading', () => {
it('respects the is prop', () => {
expect(render(<Heading is="h6" />).type).toEqual('h6')
})
it('renders margin', () => {
expect(render(<Heading m={1} theme={theme} />)).toHaveStyleRule('margin', '4px')
expect(render(<Heading m={[0, 1, 2, 3, 4]} theme={theme} />)).toMatchSnapshot()
expect(render(<Heading m={[1, 1, 3, 3]} theme={theme} />)).toMatchSnapshot()
})

it('renders padding', () => {
expect(render(<Heading p={1} theme={theme} />)).toHaveStyleRule('padding', '4px')
expect(render(<Heading p={[0, 1, 2, 3, 4]} theme={theme} />)).toMatchSnapshot()
expect(render(<Heading p={[1, 1, 3, 3]} theme={theme} />)).toMatchSnapshot()
})

it('respects color', () => {
expect(render(<Heading color="green.5" theme={theme} />)).toHaveStyleRule('color', theme.colors.green[5])
})

it('respects fontWeight', () => {
expect(render(<Heading fontWeight="bold" theme={theme} />)).toHaveStyleRule('font-weight', 'bold')
Expand Down
8 changes: 0 additions & 8 deletions src/__tests__/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,4 @@ describe('Label', () => {
it('implements space system props', () => {
expect(Label).toImplementSystemProps(['space'])
})

it('respects margin utility prop', () => {
expect(render(<Label m={4} />)).toMatchSnapshot()
})

it('respects padding utility prop', () => {
expect(render(<Label p={4} />)).toMatchSnapshot()
})
})
7 changes: 0 additions & 7 deletions src/__tests__/Link.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable jsx-a11y/anchor-has-content, jsx-a11y/anchor-is-valid */
import React from 'react'
import Link from '../Link'
import theme from '../theme'
import {render, renderClasses} from '../utils/testing'
import {COMMON} from '../system-props'

Expand Down Expand Up @@ -34,10 +33,4 @@ describe('Link', () => {
it('renders without any props', () => {
expect(render(<Link />)).toMatchSnapshot()
})

it('renders margin', () => {
expect(render(<Link m={1} theme={theme} />)).toMatchSnapshot()
expect(render(<Link m={[0, 1, 2, 3]} theme={theme} />)).toMatchSnapshot()
expect(render(<Link m={[1, 1, 1, 3]} theme={theme} />)).toMatchSnapshot()
})
})
8 changes: 4 additions & 4 deletions src/__tests__/OcticonButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ describe('OcticonButton', () => {
})

it('renders a button with an Octicon', () => {
expect(render(<OcticonButton icon={Circle} />)).toMatchSnapshot()
expect(render(<OcticonButton icon={Circle} label="circle" />)).toMatchSnapshot()
})

it('respects the "disabled" prop', () => {
expect(render(<OcticonButton icon={Circle} disabled />).props.disabled).toBe(true)
expect(render(<OcticonButton icon={Circle} disabled label="circle" />).props.disabled).toBe(true)
})

it('sets "aria-label" to the "label" prop', () => {
Expand All @@ -29,10 +29,10 @@ describe('OcticonButton', () => {

it('passes the onClick handler to the <button>', () => {
function click() {}
expect(render(<OcticonButton icon={Circle} onClick={click} />).props.onClick).toEqual(click)
expect(render(<OcticonButton icon={Circle} onClick={click} label="circle" />).props.onClick).toEqual(click)
})

it('passes the "size" prop to the Octicon', () => {
expect(render(<OcticonButton icon={Circle} size={128} />)).toMatchSnapshot()
expect(render(<OcticonButton icon={Circle} size={128} label="circle" />)).toMatchSnapshot()
})
})
Loading