Skip to content

Commit f08e3ab

Browse files
committed
Update functional tests
1 parent f3abe08 commit f08e3ab

4 files changed

Lines changed: 22 additions & 0 deletions

File tree

.flowconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ node_modules/jss/flow-typed
1010

1111
[options]
1212
all=true
13+
suppress_comment= \\(.\\|\n\\)*\\$FlowFixMe
14+
suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore

src/tests/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ rules:
33
- error
44
- devDependencies: true
55
react/require-default-props: off
6+
global-require: off

src/tests/functional.spec.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import React from 'react'
33
import {stripIndent} from 'common-tags'
44
import {mount} from 'enzyme'
55

6+
import {
7+
getCss,
8+
removeWhitespace
9+
} from './utils'
10+
611
import CreateApp from './App'
712

813
let Styled
@@ -18,6 +23,7 @@ const mockNameGenerators = () => {
1823
const generateTagName = require('../utils/generateTagName').default
1924
const generateClassName = require('jss/lib/utils/generateClassName').default
2025

26+
// $FlowIgnore
2127
generateTagName.mockImplementation((tagName: string) => `${tagName}-${++styledCounter}`)
2228
generateClassName.mockImplementation(rule => `${rule.name}-${++jssCounter}`)
2329
}
@@ -30,6 +36,10 @@ describe('functional tests', () => {
3036
styled = Styled()
3137
})
3238

39+
afterEach(() => {
40+
styled.mountSheet().detach()
41+
})
42+
3343
it('should update props and unmount', () => {
3444
const App = CreateApp(styled)
3545
const wrapper = mount(<App />)
@@ -146,6 +156,8 @@ describe('functional tests', () => {
146156
}
147157
`)
148158

159+
expect(getCss(sheet)).toBe(removeWhitespace(sheet.toString()))
160+
149161
wrapper.setProps({primary: true})
150162

151163
expect(sheet.toString()).toBe(stripIndent`
@@ -166,6 +178,8 @@ describe('functional tests', () => {
166178
}
167179
`)
168180

181+
expect(getCss(sheet)).toBe(removeWhitespace(sheet.toString()))
182+
169183
wrapper.unmount()
170184
})
171185
})

src/tests/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export const removeWhitespace = (str: string) => str.replace(/\s/g, '')
2+
3+
export const getCss = (sheet: Object) => sheet.renderer.getRules()
4+
.map(rule => removeWhitespace(rule.cssText))
5+
.join('')

0 commit comments

Comments
 (0)