Skip to content

Commit 8decc5f

Browse files
committed
Get specs working again
1 parent f65128a commit 8decc5f

File tree

69 files changed

+14069
-13674
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+14069
-13674
lines changed

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
"release:build": "babel-node scripts/release/build_release.js",
1414
"release:verifyBuild": "babel-node scripts/release/verify_build.js",
1515
"release:publish": "babel-node scripts/release/publish_release.js",
16-
"lint": "eslint src --ext .js,.jsx --ignore-pattern '*.spec.js'",
16+
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --ignore-pattern '*.spec.js'",
1717
"lint:fix": "npm run lint -- --fix",
1818
"test:lint": "npm run lint -- --quiet",
1919
"start": "webpack --progress --watch --config webpack.config.js",
2020
"styleguide": "styleguidist server",
2121
"styleguide:build": "styleguidist build && node scripts/moveBuildAssets.js",
22-
"test:watch": "npm test -- --watch --bail",
22+
"test:watch": "jest --watch --bail",
2323
"test": "jest --silent && npm run test:lint",
2424
"test:ci": "jest --silent --maxWorkers=2 && npm run test:lint",
2525
"test:generate-coverage-report": "codecov"
@@ -64,20 +64,21 @@
6464
"babel-loader": "^8.0.0",
6565
"codecov": "^3.5.0",
6666
"coveralls": "^3.0.5",
67-
"enzyme": "^3.3.0",
68-
"enzyme-adapter-react-16": "^1.1.1",
69-
"enzyme-to-json": "^3.3.3",
67+
"enzyme": "^3.10.0",
68+
"enzyme-adapter-react-16": "^1.14.0",
69+
"enzyme-to-json": "^3.4.0",
7070
"eslint": "5.16.0",
7171
"eslint-import-resolver-webpack": "0.11.0",
7272
"fs-extra": "^5.0.0",
7373
"glob": "7.1.4",
7474
"jest": "^24.8.0",
75+
"jest-emotion": "10.0.14",
7576
"prettier": "1.16.4",
7677
"prompt": "^1.0.0",
7778
"react": "16.4.2",
7879
"react-dom": "16.4.2",
7980
"react-styleguidist": "9.0.9",
80-
"react-test-renderer": "^16.2.0",
81+
"react-test-renderer": "16.4.2",
8182
"react-transition-group": "^2.2.1",
8283
"sinon": "^7.3.2",
8384
"typescript": "^3.2.2",
@@ -112,6 +113,7 @@
112113
"transform": {
113114
"^.+\\.js$": "babel-jest"
114115
},
116+
"snapshotSerializers": ["jest-emotion"],
115117
"coverageDirectory": "./coverage/",
116118
"testURL": "http://localhost",
117119
"collectCoverage": true,

src/components/Buttons/__tests__/Button.spec.js

Lines changed: 23 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
22
import renderer from 'react-test-renderer'
3-
import { StyleRoot } from 'radium'
43
import { mount } from 'enzyme'
54
import { spy } from 'sinon'
65
import Icon from '../../Icon/Icon'
@@ -16,13 +15,7 @@ describe('Button', () => {
1615
]
1716

1817
testCases.forEach(props => {
19-
const tree = renderer
20-
.create(
21-
<StyleRoot>
22-
<Button {...props}>Primary Button</Button>
23-
</StyleRoot>
24-
)
25-
.toJSON()
18+
const tree = renderer.create(<Button {...props}>Primary Button</Button>).toJSON()
2619
expect(tree).toMatchSnapshot()
2720
})
2821
})
@@ -36,25 +29,17 @@ describe('Button', () => {
3629
]
3730

3831
testCases.forEach(props => {
39-
const tree = renderer
40-
.create(
41-
<StyleRoot>
42-
<Button {...props}>Hi</Button>
43-
</StyleRoot>
44-
)
45-
.toJSON()
32+
const tree = renderer.create(<Button {...props}>Hi</Button>).toJSON()
4633
expect(tree).toMatchSnapshot()
4734
})
4835
})
4936

5037
it('renders with inverted colors', () => {
5138
const tree = renderer
5239
.create(
53-
<StyleRoot>
54-
<Button inverted snacksType="primary" size="small">
55-
Hi
56-
</Button>
57-
</StyleRoot>
40+
<Button inverted snacksType="primary" size="small">
41+
Hi
42+
</Button>
5843
)
5944
.toJSON()
6045
expect(tree).toMatchSnapshot()
@@ -69,25 +54,17 @@ describe('Button', () => {
6954
]
7055

7156
testCases.forEach(props => {
72-
const tree = renderer
73-
.create(
74-
<StyleRoot>
75-
<Button {...props}>Hi</Button>
76-
</StyleRoot>
77-
)
78-
.toJSON()
57+
const tree = renderer.create(<Button {...props}>Hi</Button>).toJSON()
7958
expect(tree).toMatchSnapshot()
8059
})
8160
})
8261

8362
it('applies the elementAttributes prop correctly', () => {
8463
const tree = renderer
8564
.create(
86-
<StyleRoot>
87-
<Button elementAttributes={{ 'aria-label': 'foo' }} nacksType="primary">
88-
Hi
89-
</Button>
90-
</StyleRoot>
65+
<Button elementAttributes={{ 'aria-label': 'foo' }} nacksType="primary">
66+
Hi
67+
</Button>
9168
)
9269
.toJSON()
9370
expect(tree).toMatchSnapshot()
@@ -96,13 +73,11 @@ describe('Button', () => {
9673
it('fires the onClick prop', () => {
9774
const onClick = spy()
9875
const wrapper = mount(
99-
<StyleRoot>
100-
<div>
101-
<Button snacksType="primary" onClick={onClick}>
102-
Hi
103-
</Button>
104-
</div>
105-
</StyleRoot>
76+
<div>
77+
<Button snacksType="primary" onClick={onClick}>
78+
Hi
79+
</Button>
80+
</div>
10681
)
10782

10883
wrapper.find('button').simulate('click')
@@ -113,11 +88,9 @@ describe('Button', () => {
11388
it('renders correctly when disabled', () => {
11489
const tree = renderer
11590
.create(
116-
<StyleRoot>
117-
<Button disabled snacksType="primary">
118-
Hi
119-
</Button>
120-
</StyleRoot>
91+
<Button disabled snacksType="primary">
92+
Hi
93+
</Button>
12194
)
12295
.toJSON()
12396
expect(tree).toMatchSnapshot()
@@ -126,11 +99,9 @@ describe('Button', () => {
12699
it('does not fire the onClick prop when disabled', () => {
127100
const onClick = spy()
128101
const wrapper = mount(
129-
<StyleRoot>
130-
<Button disabled snacksType="primary">
131-
Hi
132-
</Button>
133-
</StyleRoot>
102+
<Button disabled snacksType="primary">
103+
Hi
104+
</Button>
134105
)
135106

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

141112
it('can render as a link if an href is provided', () => {
142113
const tree = renderer.create(
143-
<StyleRoot>
144-
<Button href="/carrot" snacksType="primary">
145-
Hi
146-
</Button>
147-
</StyleRoot>
114+
<Button href="/carrot" snacksType="primary">
115+
Hi
116+
</Button>
148117
)
149118
expect(tree).toMatchSnapshot()
150119
})

src/components/Buttons/__tests__/CircleButton.spec.js

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
22
import renderer from 'react-test-renderer'
3-
import { StyleRoot } from 'radium'
43
import { mount } from 'enzyme'
54
import { spy } from 'sinon'
65
import Icon from '../../Icon/Icon'
@@ -9,11 +8,9 @@ import CircleButton from '../CircleButton'
98
it('renders basic CircleButton correctly', () => {
109
const tree = renderer
1110
.create(
12-
<StyleRoot>
13-
<div>
14-
<CircleButton>1</CircleButton>
15-
</div>
16-
</StyleRoot>
11+
<div>
12+
<CircleButton>1</CircleButton>
13+
</div>
1714
)
1815
.toJSON()
1916
expect(tree).toMatchSnapshot()
@@ -22,13 +19,11 @@ it('renders basic CircleButton correctly', () => {
2219
it('renders CircleButton with Icon correctly', () => {
2320
const tree = renderer
2421
.create(
25-
<StyleRoot>
26-
<div>
27-
<CircleButton>
28-
<Icon name="arrowLeftSmallBold" />
29-
</CircleButton>
30-
</div>
31-
</StyleRoot>
22+
<div>
23+
<CircleButton>
24+
<Icon name="arrowLeftSmallBold" />
25+
</CircleButton>
26+
</div>
3227
)
3328
.toJSON()
3429
expect(tree).toMatchSnapshot()
@@ -37,19 +32,17 @@ it('renders CircleButton with Icon correctly', () => {
3732
it('renders CircleButton with passed style prop correctly', () => {
3833
const tree = renderer
3934
.create(
40-
<StyleRoot>
41-
<div>
42-
<CircleButton
43-
style={{
44-
top: '8px',
45-
right: '8px',
46-
position: 'absolute',
47-
}}
48-
>
49-
1
50-
</CircleButton>
51-
</div>
52-
</StyleRoot>
35+
<div>
36+
<CircleButton
37+
style={{
38+
top: '8px',
39+
right: '8px',
40+
position: 'absolute',
41+
}}
42+
>
43+
1
44+
</CircleButton>
45+
</div>
5346
)
5447
.toJSON()
5548
expect(tree).toMatchSnapshot()
@@ -58,11 +51,9 @@ it('renders CircleButton with passed style prop correctly', () => {
5851
it('renders CircleButton with passed ariaLabel correctly', () => {
5952
const tree = renderer
6053
.create(
61-
<StyleRoot>
62-
<div>
63-
<CircleButton ariaLabel={'this is a button test'}>1</CircleButton>
64-
</div>
65-
</StyleRoot>
54+
<div>
55+
<CircleButton ariaLabel={'this is a button test'}>1</CircleButton>
56+
</div>
6657
)
6758
.toJSON()
6859
expect(tree).toMatchSnapshot()
@@ -71,11 +62,9 @@ it('renders CircleButton with passed ariaLabel correctly', () => {
7162
it('renders CircleButton with passed disabled prop correctly', () => {
7263
const tree = renderer
7364
.create(
74-
<StyleRoot>
75-
<div>
76-
<CircleButton disabled>1</CircleButton>
77-
</div>
78-
</StyleRoot>
65+
<div>
66+
<CircleButton disabled>1</CircleButton>
67+
</div>
7968
)
8069
.toJSON()
8170
expect(tree).toMatchSnapshot()
@@ -84,11 +73,9 @@ it('renders CircleButton with passed disabled prop correctly', () => {
8473
it('calls onClick callback correctly', () => {
8574
const onClick = spy()
8675
const CButton = mount(
87-
<StyleRoot>
88-
<div>
89-
<CircleButton onClick={onClick}>1</CircleButton>
90-
</div>
91-
</StyleRoot>
76+
<div>
77+
<CircleButton onClick={onClick}>1</CircleButton>
78+
</div>
9279
)
9380

9481
const button = CButton.find('button').first()
@@ -99,13 +86,11 @@ it('calls onClick callback correctly', () => {
9986
it('does not call onClick when disabled prop is true', () => {
10087
const onClick = spy()
10188
const CButton = mount(
102-
<StyleRoot>
103-
<div>
104-
<CircleButton onClick={onClick} disabled>
105-
1
106-
</CircleButton>
107-
</div>
108-
</StyleRoot>
89+
<div>
90+
<CircleButton onClick={onClick} disabled>
91+
1
92+
</CircleButton>
93+
</div>
10994
)
11095

11196
const button = CButton.find('button').first()

0 commit comments

Comments
 (0)