forked from cssinjs/jss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateUseStyles.test.js
More file actions
44 lines (37 loc) · 1.17 KB
/
createUseStyles.test.js
File metadata and controls
44 lines (37 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* eslint-disable react/prop-types */
import * as React from 'react'
import {renderToString} from 'react-dom/server'
import expect from 'expect.js'
import {stripIndent} from 'common-tags'
import createCommonBaseTests from '../test-utils/createCommonBaseTests'
import {createUseStyles, JssProvider, SheetsRegistry} from '.'
const createStyledComponent = (styles, options) => {
const useStyles = createUseStyles(styles, options)
const Comp = props => {
useStyles(props)
return null
}
return Comp
}
describe('React-JSS: createUseStyles', () => {
createCommonBaseTests({createStyledComponent})
describe('theme prop', () => {
it('should pass theme from props priority', () => {
const registry = new SheetsRegistry()
const styles = theme => ({
button: {color: theme.exampleColor || 'green'}
})
const MyComponent = createStyledComponent(styles)
renderToString(
<JssProvider registry={registry} generateId={() => 'button'}>
<MyComponent theme={{exampleColor: 'blue'}} />
</JssProvider>
)
expect(registry.toString()).to.be(stripIndent`
.button {
color: blue;
}
`)
})
})
})