-
-
Notifications
You must be signed in to change notification settings - Fork 106
/
cx.test.tsx
52 lines (48 loc) Β· 1.06 KB
/
cx.test.tsx
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
45
46
47
48
49
50
51
52
/** @jsx jsx */
import { jsx } from '@emotion/react'
import '@testing-library/jest-dom/extend-expect'
import { render, cleanup } from '@testing-library/react'
import { css, cx } from '.'
afterEach(cleanup)
describe('#cx', () => {
it('throws with string value', () => {
expect(() => render(<div css={cx(`margin: 2px`)} />)).toThrow(
'Strings are not allowed as css prop values',
)
})
it('handles css values', () => {
const { container } = render(
<div
css={cx(
css`
margin: 2;
padding: 1;
margin-top: 2px;
`,
)}
/>,
)
expect(container.firstChild).toHaveStyle(`
margin: 2px 8px 8px 8px;
padding: 4px;
`)
})
it('handles multiple css values', () => {
const { container } = render(
<div
css={cx([
css`
margin: 2;
`,
css`
padding: 1;
`,
])}
/>,
)
expect(container.firstChild).toHaveStyle(`
margin: 8px;
padding: 4px;
`)
})
})