-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathwarnings.test.js
45 lines (39 loc) · 1.56 KB
/
warnings.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
import 'test-utils/setup-env'
import { css } from '@emotion/css'
console.error = jest.fn()
afterEach(() => {
jest.clearAllMocks()
})
test('warns about illegal escape sequences inside first quasi of template literal', () => {
css`
:before {
content: '\00d7';
}
`
expect(console.error.mock.calls[0]).toMatchInlineSnapshot(`
[
"You have illegal escape sequence in your template literal, most likely inside content's property value.
Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example "content: '\\00d7';" should become "content: '\\\\00d7';".
You can read more about this here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",
]
`)
})
test('warns about illegal escape sequences inside non-first quasi of template literal', () => {
const color = `color: hotpink`
css`
background-color: black;
${color};
:before {
content: '\00d7';
}
`
expect(console.error.mock.calls[0]).toMatchInlineSnapshot(`
[
"You have illegal escape sequence in your template literal, most likely inside content's property value.
Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example "content: '\\00d7';" should become "content: '\\\\00d7';".
You can read more about this here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#ES2018_revision_of_illegal_escape_sequences",
]
`)
})