-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathinject-global.test.js
77 lines (75 loc) · 1.67 KB
/
inject-global.test.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import 'test-utils/setup-env'
import { injectGlobal, sheet, flush, css } from '@emotion/css'
describe('injectGlobal', () => {
afterEach(() => {
flush()
})
test('basic', () => {
injectGlobal`
html {
background: pink;
}
html.active {
background: red;
}
`
expect(sheet).toMatchSnapshot()
})
test('interpolated value', () => {
const color = 'yellow'
injectGlobal`
body {
color: ${color};
margin: 0;
padding: 0;
}
`
expect(sheet).toMatchSnapshot()
})
test('nested interpolated media query', () => {
injectGlobal`
body {
${'@media (max-width: 600px)'} {
display: flex;
}
}
`
expect(sheet).toMatchSnapshot()
})
test('random interpolation', () => {
const cls = css`
display: flex;
`
injectGlobal`
body {
${cls};
}
`
expect(sheet).toMatchSnapshot()
})
test('with @font-face', () => {
injectGlobal`
@font-face {
font-family: 'Patrick Hand SC';
font-style: normal;
font-weight: 400;
src: local('Patrick Hand SC'), local('PatrickHandSC-Regular'),
url(https://fonts.gstatic.com/s/patrickhandsc/v4/OYFWCgfCR-7uHIovjUZXsZ71Uis0Qeb9Gqo8IZV7ckE.woff2)
format('woff2');
unicode-range: U+0100-024f, U+1-1eff, U+20a0-20ab, U+20ad-20cf,
U+2c60-2c7f, U+A720-A7FF;
}
`
expect(sheet).toMatchSnapshot()
})
test('pseudo in @media', () => {
injectGlobal`
@media (min-width: 300px) {
.header:after {
content: '';
}
}
`
expect(sheet).toMatchSnapshot()
})
})