Skip to content

Commit b8dde00

Browse files
committed
Update functional tests
1 parent c51d8db commit b8dde00

2 files changed

Lines changed: 87 additions & 87 deletions

File tree

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
exports[`functional tests should update nested props 1`] = `
2+
".button-id {
3+
font-size: 12px;
4+
}
5+
.div-1-id {
6+
padding: 15px;
7+
}
8+
.div-3-id:hover .button-id {
9+
color: green;
10+
}
11+
.div-4-id:hover .button-id {
12+
color: red;
13+
}"
14+
`;
15+
16+
exports[`functional tests should update nested props 2`] = `
17+
".button-id {
18+
font-size: 12px;
19+
}
20+
.div-1-id {
21+
padding: 15px;
22+
}
23+
.div-3-id:hover .button-id {
24+
color: red;
25+
}
26+
.div-4-id:hover .button-id {
27+
color: green;
28+
}"
29+
`;
30+
31+
exports[`functional tests should update props and unmount 1`] = `
32+
".div-1-id {
33+
margin: 50px;
34+
}
35+
.header-2-id {
36+
padding: 10px;
37+
}
38+
.h1-5-id {
39+
color: red;
40+
}
41+
.section-3-id {
42+
color: red;
43+
}
44+
.button-6-id {
45+
margin: 0;
46+
}
47+
.button-7-id {
48+
margin: 10px;
49+
}
50+
.section-4-id {
51+
color: yellow;
52+
}"
53+
`;
54+
55+
exports[`functional tests should update props and unmount 2`] = `
56+
".div-1-id {
57+
margin: 50px;
58+
}
59+
.header-2-id {
60+
padding: 10px;
61+
}
62+
.h1-5-id {
63+
color: red;
64+
}
65+
.section-3-id {
66+
color: red;
67+
}
68+
.button-6-id {
69+
margin: 0;
70+
}
71+
.button-7-id {
72+
margin: 20px;
73+
}
74+
.section-4-id {
75+
color: yellow;
76+
}"
77+
`;

src/tests/functional.spec.jsx

Lines changed: 10 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import 'react-dom'
22
import React from 'react'
3-
import {stripIndent} from 'common-tags'
43
import {mount} from 'enzyme'
54

65
import {
@@ -15,7 +14,6 @@ let styled
1514

1615
const mockNameGenerators = () => {
1716
let styledCounter = 0
18-
let jssCounter = 0
1917

2018
jest.mock('../utils/generateTagName')
2119
jest.mock('jss/lib/utils/generateClassName')
@@ -25,7 +23,12 @@ const mockNameGenerators = () => {
2523

2624
// $FlowIgnore
2725
generateTagName.mockImplementation((tagName: string) => `${tagName}-${++styledCounter}`)
28-
generateClassName.mockImplementation(rule => `${rule.name}-${++jssCounter}`)
26+
generateClassName.mockImplementation(rule => `${rule.name}-id`)
27+
}
28+
29+
const assertSheet = (sheet) => {
30+
expect(sheet.toString()).toMatchSnapshot()
31+
expect(getCss(sheet)).toBe(removeWhitespace(sheet.toString()))
2932
}
3033

3134
describe('functional tests', () => {
@@ -45,56 +48,9 @@ describe('functional tests', () => {
4548
const wrapper = mount(<App />)
4649
const sheet = styled.mountSheet()
4750

48-
expect(sheet.toString()).toBe(stripIndent`
49-
.div-1-1 {
50-
margin: 50px;
51-
}
52-
.header-2-2 {
53-
padding: 10px;
54-
}
55-
.h1-5-3 {
56-
color: red;
57-
}
58-
.section-3-4 {
59-
color: red;
60-
}
61-
.button-6-5 {
62-
margin: 0;
63-
}
64-
.button-7-6 {
65-
margin: 10px;
66-
}
67-
.section-4-7 {
68-
color: yellow;
69-
}
70-
`)
71-
51+
assertSheet(sheet)
7252
wrapper.setProps({margin: 20})
73-
74-
expect(sheet.toString()).toBe(stripIndent`
75-
.div-1-1 {
76-
margin: 50px;
77-
}
78-
.header-2-2 {
79-
padding: 10px;
80-
}
81-
.h1-5-3 {
82-
color: red;
83-
}
84-
.section-3-4 {
85-
color: red;
86-
}
87-
.button-6-5 {
88-
margin: 0;
89-
}
90-
.button-7-6 {
91-
margin: 20px;
92-
}
93-
.section-4-7 {
94-
color: yellow;
95-
}
96-
`)
97-
53+
assertSheet(sheet)
9854
wrapper.unmount()
9955
})
10056

@@ -132,42 +88,9 @@ describe('functional tests', () => {
13288
const wrapper = mount(<App />)
13389
const sheet = styled.mountSheet()
13490

135-
expect(sheet.toString()).toBe(stripIndent`
136-
.button-1 {
137-
font-size: 12px;
138-
}
139-
.div-1-2 {
140-
padding: 15px;
141-
}
142-
.div-3-3:hover .button-1 {
143-
color: green;
144-
}
145-
.div-4-7:hover .button-1 {
146-
color: red;
147-
}
148-
`)
149-
150-
expect(getCss(sheet)).toBe(removeWhitespace(sheet.toString()))
151-
91+
assertSheet(sheet)
15292
wrapper.setProps({primary: true})
153-
154-
expect(sheet.toString()).toBe(stripIndent`
155-
.button-1 {
156-
font-size: 12px;
157-
}
158-
.div-1-2 {
159-
padding: 15px;
160-
}
161-
.div-3-3:hover .button-1 {
162-
color: red;
163-
}
164-
.div-4-7:hover .button-1 {
165-
color: green;
166-
}
167-
`)
168-
169-
expect(getCss(sheet)).toBe(removeWhitespace(sheet.toString()))
170-
93+
assertSheet(sheet)
17194
wrapper.unmount()
17295
})
17396
})

0 commit comments

Comments
 (0)