Skip to content

Commit 5c88ec7

Browse files
committed
Update tests for jss v9.3.1
1 parent eb311b4 commit 5c88ec7

6 files changed

Lines changed: 29 additions & 15 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"common-tags": "^1.4.0",
5959
"copyfiles": "^1.2.0",
6060
"coveralls": "^3.0.0",
61+
"css.escape": "^1.5.1",
6162
"enzyme": "^3.1.0",
6263
"enzyme-adapter-react-16": "^1.0.1",
6364
"enzyme-to-json": "^3.1.2",
@@ -94,7 +95,8 @@
9495
"rootDir": "src",
9596
"coverageDirectory": "../coverage",
9697
"setupFiles": [
97-
"raf/polyfill"
98+
"raf/polyfill",
99+
"css.escape"
98100
],
99101
"snapshotSerializers": [
100102
"enzyme-to-json/serializer"

src/tests/__snapshots__/functional.spec.jsx.snap

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`functional tests Compose React Components should escape name 1`] = `
4-
".\\\\(Comp\\\\.name\\\\)-1-id {
3+
exports[`functional tests Compose React Components should escape name in dev mode 1`] = `
4+
".(Comp.name)-1-id {
55
color: red;
66
}"
77
`;
@@ -105,6 +105,8 @@ exports[`functional tests should update dynamic props for conditional rules 1`]
105105
padding: 10px;
106106
}
107107
@media screen {
108+
.button-1-id {
109+
}
108110
.button-1-id .button {
109111
margin: 10px;
110112
}
@@ -116,6 +118,8 @@ exports[`functional tests should update dynamic props for conditional rules 2`]
116118
padding: 0;
117119
}
118120
@media screen {
121+
.button-1-id {
122+
}
119123
.button-1-id .button {
120124
margin: 0;
121125
}
@@ -129,9 +133,19 @@ exports[`functional tests should update nested props 1`] = `
129133
.div-1-id {
130134
padding: 15px;
131135
}
136+
.div-3-id {
137+
}
138+
.div-3-id:hover {
139+
}
132140
.div-3-id:hover .button-id {
133141
color: green;
134142
}
143+
.button-2-id {
144+
}
145+
.div-4-id {
146+
}
147+
.div-4-id:hover {
148+
}
135149
.div-4-id:hover .button-id {
136150
color: red;
137151
}"
@@ -227,7 +241,9 @@ exports[`functional tests should use Styled Component classname in string 1`] =
227241
`;
228242

229243
exports[`functional tests should use Styled Component classname in string 2`] = `
230-
".div-4-id:not(:first-child) .static-2-id {
244+
".div-4-id {
245+
}
246+
.div-4-id:not(:first-child) .static-2-id {
231247
display: none;
232248
}
233249
.div-4-id:not(:last-child) .static-3-id {

src/tests/functional.spec.jsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import Observable from 'zen-observable'
44
import Enzyme, {mount} from 'enzyme'
55
import Adapter from 'enzyme-adapter-react-16'
66

7-
import escapeClassName from '../utils/escapeClassName'
8-
97
import {
108
getCss,
119
removeWhitespace
@@ -28,7 +26,7 @@ const mockNameGenerators = () => {
2826
const createGenerateClassName = require('jss/lib/utils/createGenerateClassName').default
2927

3028
// $FlowIgnore there is now mockImplementation in declaration
31-
generateTagName.mockImplementation((tagName: string) => `${escapeClassName(tagName)}-${++styledCounter}`)
29+
generateTagName.mockImplementation((tagName: string) => `${tagName}-${++styledCounter}`)
3230
createGenerateClassName.mockImplementation(() => rule => `${rule.key}-id`)
3331
}
3432

@@ -190,7 +188,7 @@ describe('functional tests', () => {
190188
assertSheet(styled.sheet)
191189
})
192190

193-
it('should escape name', () => {
191+
it('should escape name in dev mode', () => {
194192
const Comp = ({className}: {className: string}) => (
195193
<div className={className}>Container</div>
196194
)
@@ -204,7 +202,6 @@ describe('functional tests', () => {
204202
const wrapper = mount(<Container />)
205203
const {sheet} = styled
206204

207-
expect(sheet.rules.index[0].selectorText).toBe('.\\(Comp\\.name\\)-1-id')
208205
assertSheet(sheet)
209206

210207
wrapper.unmount()

src/utils/escapeClassName.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/utils/generateTagName.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import escapeClassName from './escapeClassName'
2-
31
let tagNameCounter = 0
42

5-
export default (tagName: string) => `${escapeClassName(tagName)}-${++tagNameCounter}`
3+
export default (tagName: string) => `${tagName}-${++tagNameCounter}`

yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,10 @@ css-what@2.1:
12321232
version "2.1.0"
12331233
resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.0.tgz#9467d032c38cfaefb9f2d79501253062f87fa1bd"
12341234

1235+
css.escape@^1.5.1:
1236+
version "1.5.1"
1237+
resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb"
1238+
12351239
cssom@0.3.x, "cssom@>= 0.3.2 < 0.4.0":
12361240
version "0.3.2"
12371241
resolved "https://registry.yarnpkg.com/cssom/-/cssom-0.3.2.tgz#b8036170c79f07a90ff2f16e22284027a243848b"

0 commit comments

Comments
 (0)