-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathsource-map.test.js
62 lines (56 loc) · 1.3 KB
/
source-map.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
import 'test-utils/setup-env'
import { css, sheet, flush } from '@emotion/css'
const commentPattern = /\/\*[\s\S]*?\*\//g
const getStyles = sheet =>
sheet.tags
.map(tag => tag.textContent || '')
.join('')
.replace(commentPattern, '\n$&\n')
describe('css', () => {
afterEach(() => flush())
test('source-map nested styles', () => {
const mq = [
'@media(min-width: 420px)',
'@media(min-width: 640px)',
'@media(min-width: 960px)'
]
css({
color: 'blue',
'&:hover': {
'& .name': {
color: 'amethyst',
'&:focus': {
color: 'burlywood',
[mq[0]]: {
color: 'rebeccapurple'
}
}
},
color: 'green'
}
})
expect(getStyles(sheet)).toMatchSnapshot()
})
test('source-map nested media queries', () => {
css`
@media (max-width: 600px) {
h1 {
font-size: 1.4rem;
}
}
@media (max-width: 400px), (max-height: 420px) {
h1 {
font-size: 1.1rem;
}
}
`
expect(getStyles(sheet)).toMatchSnapshot()
})
test('css without newline or semicolon', () => {
// eslint-disable-next-line
const cls = css`
color: hotpink;
`
expect(getStyles(sheet)).toMatchSnapshot()
})
})