Skip to content

Commit b9e3da2

Browse files
committed
Fix sheet.update() test, add test for .addRule with function value
1 parent c6ff8dd commit b9e3da2

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

tests/functional/sheet.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,34 @@ describe('Functional: sheet', () => {
247247
})
248248
})
249249

250+
describe('.addRule() with just function values and attached sheet', () => {
251+
let style
252+
let sheet
253+
254+
beforeEach(() => {
255+
sheet = jss.createStyleSheet().attach().link()
256+
sheet.addRule('a', {color: ({color}) => color})
257+
style = getStyle()
258+
})
259+
260+
afterEach(() => {
261+
sheet.detach()
262+
})
263+
264+
it('should render an empty rule', () => {
265+
expect(getCss(style)).to.be(removeWhitespace(sheet.toString()))
266+
})
267+
268+
it('should render rule with updated color', () => {
269+
sheet.update({color: 'red'})
270+
expect(sheet.toString()).to.be(stripIndent`
271+
.a-id {
272+
color: red;
273+
}
274+
`)
275+
})
276+
})
277+
250278
describe('.addRule() with empty styles', () => {
251279
let sheet
252280
let style
@@ -449,7 +477,14 @@ describe('Functional: sheet', () => {
449477
})
450478

451479
it('should return correct .toString()', () => {
452-
expect(sheet.toString()).to.be('')
480+
expect(sheet.toString()).to.be(stripIndent`
481+
.a-id {
482+
}
483+
@media all {
484+
.b-id {
485+
}
486+
}
487+
`)
453488

454489
sheet.update({
455490
color: 'green'

0 commit comments

Comments
 (0)