1
1
import expect from 'expect.js'
2
2
import { stripIndent } from 'common-tags'
3
3
import { create } from 'jss'
4
+ import { getCss , getStyle , removeWhitespace , resetSheets } from '../../../tests/utils'
4
5
import pluginNested from '../../jss-plugin-nested'
5
6
import pluginFunction from '.'
6
7
7
- const settings = { createGenerateId : ( ) => ( rule ) => `${ rule . key } -id` }
8
+ const settings = { createGenerateId : ( ) => rule => `${ rule . key } -id` }
8
9
9
10
describe ( 'jss-plugin-rule-value-function: plugin-nested' , ( ) => {
10
11
let jss
@@ -20,7 +21,7 @@ describe('jss-plugin-rule-value-function: plugin-nested', () => {
20
21
sheet = jss
21
22
. createStyleSheet (
22
23
{
23
- a : ( data ) => ( {
24
+ a : data => ( {
24
25
color : data . color ,
25
26
'@media all' : {
26
27
color : 'green'
@@ -60,7 +61,7 @@ describe('jss-plugin-rule-value-function: plugin-nested', () => {
60
61
{
61
62
a : {
62
63
color : 'red' ,
63
- '@media all' : ( data ) => ( {
64
+ '@media all' : data => ( {
64
65
color : data . color
65
66
} )
66
67
}
@@ -92,6 +93,8 @@ describe('jss-plugin-rule-value-function: plugin-nested', () => {
92
93
describe ( 'nested selector inside of a fn rule' , ( ) => {
93
94
let sheet
94
95
96
+ beforeEach ( resetSheets ( ) )
97
+
95
98
beforeEach ( ( ) => {
96
99
sheet = jss
97
100
. createStyleSheet (
@@ -123,6 +126,33 @@ describe('jss-plugin-rule-value-function: plugin-nested', () => {
123
126
}
124
127
` )
125
128
} )
129
+
130
+ describe ( 'issue #1360: no memory leak' , ( ) => {
131
+ beforeEach ( ( ) => {
132
+ sheet . update ( { color : 'green' } )
133
+ sheet . update ( { color : 'red' } )
134
+ sheet . update ( { color : 'yellow' } )
135
+ sheet . update ( { color : 'green' } )
136
+ } )
137
+
138
+ const expectedCSS = stripIndent `
139
+ .a-id {
140
+ color: red;
141
+ }
142
+ .a-id a {
143
+ color: green;
144
+ }
145
+ `
146
+ it ( 'sheet' , ( ) => {
147
+ expect ( sheet . toString ( ) ) . to . be ( expectedCSS )
148
+ } )
149
+
150
+ it ( 'DOM' , ( ) => {
151
+ const style = getStyle ( )
152
+ const css = getCss ( style )
153
+ expect ( css ) . to . be ( removeWhitespace ( expectedCSS ) )
154
+ } )
155
+ } )
126
156
} )
127
157
128
158
describe ( 'nested selector as a fn rule' , ( ) => {
0 commit comments