@@ -248,26 +248,34 @@ describe('gridstack', function() {
248
248
document . body . removeChild ( document . getElementById ( 'gs-cont' ) ) ;
249
249
} ) ;
250
250
it ( 'should start at 80 then become 120' , function ( ) {
251
+ var cellHeight = 80 ;
252
+ var verticalMargin = 10 ;
251
253
var options = {
252
- cellHeight : 80 ,
253
- verticalMargin : 10 ,
254
+ cellHeight : cellHeight ,
255
+ verticalMargin : verticalMargin ,
254
256
column : 12
255
257
} ;
256
258
$ ( '.grid-stack' ) . gridstack ( options ) ;
257
259
var container = $ ( '.grid-stack' ) ;
258
260
var grid = container . data ( 'gridstack' ) ;
259
261
var rows = container . attr ( 'data-gs-current-height' ) ;
260
262
261
- expect ( grid . cellHeight ( ) ) . toBe ( 80 ) ;
262
- expect ( parseInt ( container . css ( 'height' ) ) ) . toBe ( rows * 80 + ( rows - 1 ) * 10 ) ;
263
+ expect ( grid . cellHeight ( ) ) . toBe ( cellHeight ) ;
264
+ expect ( parseInt ( container . css ( 'height' ) ) ) . toBe ( rows * cellHeight + ( rows - 1 ) * verticalMargin ) ;
265
+
266
+ grid . cellHeight ( grid . cellHeight ( ) ) ; // should be no-op
267
+ expect ( grid . cellHeight ( ) ) . toBe ( cellHeight ) ;
268
+ expect ( parseInt ( container . css ( 'height' ) ) ) . toBe ( rows * cellHeight + ( rows - 1 ) * verticalMargin ) ;
263
269
264
- grid . cellHeight ( grid . cellHeight ( ) ) ;
265
- expect ( grid . cellHeight ( ) ) . toBe ( 80 ) ;
266
- expect ( parseInt ( container . css ( 'height' ) ) ) . toBe ( rows * 80 + ( rows - 1 ) * 10 ) ;
270
+ cellHeight = 120 ; // should change and CSS actual height
271
+ grid . cellHeight ( cellHeight ) ;
272
+ expect ( grid . cellHeight ( ) ) . toBe ( cellHeight ) ;
273
+ expect ( parseInt ( container . css ( 'height' ) ) ) . toBe ( rows * cellHeight + ( rows - 1 ) * verticalMargin ) ;
267
274
268
- grid . cellHeight ( 120 ) ;
269
- expect ( grid . cellHeight ( ) ) . toBe ( 120 ) ;
270
- expect ( parseInt ( container . css ( 'height' ) ) ) . toBe ( rows * 120 + ( rows - 1 ) * 10 ) ;
275
+ cellHeight = 20 ; // should change and CSS actual height
276
+ grid . cellHeight ( cellHeight ) ;
277
+ expect ( grid . cellHeight ( ) ) . toBe ( cellHeight ) ;
278
+ expect ( parseInt ( container . css ( 'height' ) ) ) . toBe ( rows * cellHeight + ( rows - 1 ) * verticalMargin ) ;
271
279
} ) ;
272
280
} ) ;
273
281
0 commit comments