-
-
Notifications
You must be signed in to change notification settings - Fork 389
Expand file tree
/
Copy pathindex.test.js
More file actions
64 lines (56 loc) · 1.64 KB
/
index.test.js
File metadata and controls
64 lines (56 loc) · 1.64 KB
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
/* eslint-disable no-underscore-dangle */
import expect from 'expect.js'
import {create} from 'jss'
import {resetSheets} from '../../../tests/utils'
import cache from './index'
describe('jss-plugin-cache', () => {
let jss
beforeEach(resetSheets())
beforeEach(() => {
jss = create().use(cache())
})
describe('ensure cache is used', () => {
it('should not call onCreateRule', () => {
const styles = {a: {color: 'red'}}
let onCreateRuleCalled = false
// After the first call its cached.
jss.createStyleSheet(styles)
jss.use({
onCreateRule: () => {
onCreateRuleCalled = true
}
})
jss.createStyleSheet(styles)
expect(onCreateRuleCalled).to.be(false)
})
it('should not call processors on a cached rule', () => {
const styles = {a: {color: 'red'}}
let onProcessRuleCalled = false
// After the first call its cached.
jss.createStyleSheet(styles)
jss.use({
onProcessRule: () => {
onProcessRuleCalled = true
}
})
jss.createStyleSheet(styles)
expect(onProcessRuleCalled).to.be(false)
})
})
describe('linked rules should not be cached', () => {
it('should call onCreateRule', () => {
const styles = {a: {color: 'red'}}
const options = {link: true}
let onCreateRuleCalled = false
// After the first call it should not be cached.
jss.createStyleSheet(styles, options)
jss.use({
onCreateRule: () => {
onCreateRuleCalled = true
}
})
jss.createStyleSheet(styles, options)
expect(onCreateRuleCalled).to.be(true)
})
})
})