-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathelement.js
38 lines (33 loc) · 927 Bytes
/
element.js
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
/** @jsx jsx */
import { render } from '@testing-library/react'
import { jsx, css, CacheProvider, ThemeProvider } from '@emotion/react'
import createCache from '@emotion/cache'
console.error = jest.fn()
beforeEach(() => {
document.head.innerHTML = ''
jest.clearAllMocks()
})
describe('EmotionElement', () => {
test('no React hook order violations', () => {
const theme = { color: 'blue' }
const cache = createCache({ key: 'context' })
const Comp = ({ flag }) => (
<ThemeProvider theme={theme}>
<CacheProvider value={cache}>
<div
css={
flag &&
(t => css`
color: ${t.color};
`)
}
/>
</CacheProvider>
</ThemeProvider>
)
render(<Comp />)
expect(console.error).not.toHaveBeenCalled()
render(<Comp flag />)
expect(console.error).not.toHaveBeenCalled()
})
})