Skip to content

Commit

Permalink
Get specs working again
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanmarks committed Aug 27, 2019
1 parent 3b59b33 commit af4f627
Show file tree
Hide file tree
Showing 69 changed files with 14,069 additions and 13,674 deletions.
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"release:build": "babel-node scripts/release/build_release.js",
"release:verifyBuild": "babel-node scripts/release/verify_build.js",
"release:publish": "babel-node scripts/release/publish_release.js",
"lint": "eslint src --ext .js,.jsx --ignore-pattern '*.spec.js'",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --ignore-pattern '*.spec.js'",
"lint:fix": "npm run lint -- --fix",
"test:lint": "npm run lint -- --quiet",
"start": "webpack --progress --watch --config webpack.config.js",
"styleguide": "styleguidist server",
"styleguide:build": "styleguidist build && node scripts/moveBuildAssets.js",
"test:watch": "npm test -- --watch --bail",
"test:watch": "jest --watch --bail",
"test": "jest --silent && npm run test:lint",
"test:ci": "jest --silent --maxWorkers=2 && npm run test:lint",
"test:generate-coverage-report": "codecov"
Expand Down Expand Up @@ -64,20 +64,21 @@
"babel-loader": "^8.0.0",
"codecov": "^3.1.0",
"coveralls": "^3.0.2",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.3",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.4.0",
"eslint": "5.16.0",
"eslint-import-resolver-webpack": "0.11.0",
"fs-extra": "^5.0.0",
"glob": "7.1.4",
"jest": "^24.8.0",
"jest-emotion": "10.0.14",
"prettier": "1.16.4",
"prompt": "^1.0.0",
"react": "16.4.2",
"react-dom": "16.4.2",
"react-styleguidist": "9.0.9",
"react-test-renderer": "^16.2.0",
"react-test-renderer": "16.4.2",
"react-transition-group": "^2.2.1",
"sinon": "^2.3.8",
"typescript": "^3.2.2",
Expand Down Expand Up @@ -112,6 +113,7 @@
"transform": {
"^.+\\.js$": "babel-jest"
},
"snapshotSerializers": ["jest-emotion"],
"coverageDirectory": "./coverage/",
"testURL": "http://localhost",
"collectCoverage": true,
Expand Down
77 changes: 23 additions & 54 deletions src/components/Buttons/__tests__/Button.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import renderer from 'react-test-renderer'
import { StyleRoot } from 'radium'
import { mount } from 'enzyme'
import { spy } from 'sinon'
import Icon from '../../Icon/Icon'
Expand All @@ -16,13 +15,7 @@ describe('Button', () => {
]

testCases.forEach(props => {
const tree = renderer
.create(
<StyleRoot>
<Button {...props}>Primary Button</Button>
</StyleRoot>
)
.toJSON()
const tree = renderer.create(<Button {...props}>Primary Button</Button>).toJSON()
expect(tree).toMatchSnapshot()
})
})
Expand All @@ -36,25 +29,17 @@ describe('Button', () => {
]

testCases.forEach(props => {
const tree = renderer
.create(
<StyleRoot>
<Button {...props}>Hi</Button>
</StyleRoot>
)
.toJSON()
const tree = renderer.create(<Button {...props}>Hi</Button>).toJSON()
expect(tree).toMatchSnapshot()
})
})

it('renders with inverted colors', () => {
const tree = renderer
.create(
<StyleRoot>
<Button inverted snacksType="primary" size="small">
Hi
</Button>
</StyleRoot>
<Button inverted snacksType="primary" size="small">
Hi
</Button>
)
.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -69,25 +54,17 @@ describe('Button', () => {
]

testCases.forEach(props => {
const tree = renderer
.create(
<StyleRoot>
<Button {...props}>Hi</Button>
</StyleRoot>
)
.toJSON()
const tree = renderer.create(<Button {...props}>Hi</Button>).toJSON()
expect(tree).toMatchSnapshot()
})
})

it('applies the elementAttributes prop correctly', () => {
const tree = renderer
.create(
<StyleRoot>
<Button elementAttributes={{ 'aria-label': 'foo' }} nacksType="primary">
Hi
</Button>
</StyleRoot>
<Button elementAttributes={{ 'aria-label': 'foo' }} nacksType="primary">
Hi
</Button>
)
.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -96,13 +73,11 @@ describe('Button', () => {
it('fires the onClick prop', () => {
const onClick = spy()
const wrapper = mount(
<StyleRoot>
<div>
<Button snacksType="primary" onClick={onClick}>
Hi
</Button>
</div>
</StyleRoot>
<div>
<Button snacksType="primary" onClick={onClick}>
Hi
</Button>
</div>
)

wrapper.find('button').simulate('click')
Expand All @@ -113,11 +88,9 @@ describe('Button', () => {
it('renders correctly when disabled', () => {
const tree = renderer
.create(
<StyleRoot>
<Button disabled snacksType="primary">
Hi
</Button>
</StyleRoot>
<Button disabled snacksType="primary">
Hi
</Button>
)
.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -126,11 +99,9 @@ describe('Button', () => {
it('does not fire the onClick prop when disabled', () => {
const onClick = spy()
const wrapper = mount(
<StyleRoot>
<Button disabled snacksType="primary">
Hi
</Button>
</StyleRoot>
<Button disabled snacksType="primary">
Hi
</Button>
)

wrapper.find('button').simulate('click')
Expand All @@ -140,11 +111,9 @@ describe('Button', () => {

it('can render as a link if an href is provided', () => {
const tree = renderer.create(
<StyleRoot>
<Button href="/carrot" snacksType="primary">
Hi
</Button>
</StyleRoot>
<Button href="/carrot" snacksType="primary">
Hi
</Button>
)
expect(tree).toMatchSnapshot()
})
Expand Down
81 changes: 33 additions & 48 deletions src/components/Buttons/__tests__/CircleButton.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import renderer from 'react-test-renderer'
import { StyleRoot } from 'radium'
import { mount } from 'enzyme'
import { spy } from 'sinon'
import Icon from '../../Icon/Icon'
Expand All @@ -9,11 +8,9 @@ import CircleButton from '../CircleButton'
it('renders basic CircleButton correctly', () => {
const tree = renderer
.create(
<StyleRoot>
<div>
<CircleButton>1</CircleButton>
</div>
</StyleRoot>
<div>
<CircleButton>1</CircleButton>
</div>
)
.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -22,13 +19,11 @@ it('renders basic CircleButton correctly', () => {
it('renders CircleButton with Icon correctly', () => {
const tree = renderer
.create(
<StyleRoot>
<div>
<CircleButton>
<Icon name="arrowLeftSmallBold" />
</CircleButton>
</div>
</StyleRoot>
<div>
<CircleButton>
<Icon name="arrowLeftSmallBold" />
</CircleButton>
</div>
)
.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -37,19 +32,17 @@ it('renders CircleButton with Icon correctly', () => {
it('renders CircleButton with passed style prop correctly', () => {
const tree = renderer
.create(
<StyleRoot>
<div>
<CircleButton
style={{
top: '8px',
right: '8px',
position: 'absolute',
}}
>
1
</CircleButton>
</div>
</StyleRoot>
<div>
<CircleButton
style={{
top: '8px',
right: '8px',
position: 'absolute',
}}
>
1
</CircleButton>
</div>
)
.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -58,11 +51,9 @@ it('renders CircleButton with passed style prop correctly', () => {
it('renders CircleButton with passed ariaLabel correctly', () => {
const tree = renderer
.create(
<StyleRoot>
<div>
<CircleButton ariaLabel={'this is a button test'}>1</CircleButton>
</div>
</StyleRoot>
<div>
<CircleButton ariaLabel={'this is a button test'}>1</CircleButton>
</div>
)
.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -71,11 +62,9 @@ it('renders CircleButton with passed ariaLabel correctly', () => {
it('renders CircleButton with passed disabled prop correctly', () => {
const tree = renderer
.create(
<StyleRoot>
<div>
<CircleButton disabled>1</CircleButton>
</div>
</StyleRoot>
<div>
<CircleButton disabled>1</CircleButton>
</div>
)
.toJSON()
expect(tree).toMatchSnapshot()
Expand All @@ -84,11 +73,9 @@ it('renders CircleButton with passed disabled prop correctly', () => {
it('calls onClick callback correctly', () => {
const onClick = spy()
const CButton = mount(
<StyleRoot>
<div>
<CircleButton onClick={onClick}>1</CircleButton>
</div>
</StyleRoot>
<div>
<CircleButton onClick={onClick}>1</CircleButton>
</div>
)

const button = CButton.find('button').first()
Expand All @@ -99,13 +86,11 @@ it('calls onClick callback correctly', () => {
it('does not call onClick when disabled prop is true', () => {
const onClick = spy()
const CButton = mount(
<StyleRoot>
<div>
<CircleButton onClick={onClick} disabled>
1
</CircleButton>
</div>
</StyleRoot>
<div>
<CircleButton onClick={onClick} disabled>
1
</CircleButton>
</div>
)

const button = CButton.find('button').first()
Expand Down
Loading

0 comments on commit af4f627

Please sign in to comment.