-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathsheet.dom.test.js
54 lines (46 loc) · 1.25 KB
/
sheet.dom.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
import { sheet } from '@emotion/css'
const consoleError = console.error
afterEach(() => {
console.error = consoleError
})
describe('sheet', () => {
beforeEach(() => {
sheet.flush()
})
test('speedy', () => {
expect(sheet.isSpeedy).toBe(false)
sheet.speedy(true)
expect(sheet.isSpeedy).toBe(true)
sheet.speedy(false)
expect(sheet.isSpeedy).toBe(false)
})
test('tags', () => {
sheet.speedy(true)
const rule = '.foo { color: blue; }'
sheet.insert(rule)
expect(sheet.tags).toMatchSnapshot()
expect(sheet.tags.length).toBe(1)
})
test('flush', () => {
sheet.speedy(true)
sheet.insert('.foo { color: blue; }')
sheet.flush()
expect(sheet.tags.length).toBe(0)
})
test('throws', () => {
sheet.speedy(true)
const spy = jest.fn()
console.error = spy
sheet.insert('.asdfasdf4###112121211{')
expect(spy.mock.calls.length).toBe(1)
expect(spy.mock.calls[0][0]).toMatchInlineSnapshot(
`"There was a problem inserting the following rule: ".asdfasdf4###112121211{""`
)
})
test('.speedy throws when a rule has already been inserted', () => {
sheet.insert('.foo { color: blue; }')
expect(() => {
sheet.speedy(true)
}).toThrowErrorMatchingSnapshot()
})
})