@@ -248,26 +248,34 @@ describe('gridstack', function() {
248248 document . body . removeChild ( document . getElementById ( 'gs-cont' ) ) ;
249249 } ) ;
250250 it ( 'should start at 80 then become 120' , function ( ) {
251+ var cellHeight = 80 ;
252+ var verticalMargin = 10 ;
251253 var options = {
252- cellHeight : 80 ,
253- verticalMargin : 10 ,
254+ cellHeight : cellHeight ,
255+ verticalMargin : verticalMargin ,
254256 column : 12
255257 } ;
256258 $ ( '.grid-stack' ) . gridstack ( options ) ;
257259 var container = $ ( '.grid-stack' ) ;
258260 var grid = container . data ( 'gridstack' ) ;
259261 var rows = container . attr ( 'data-gs-current-height' ) ;
260262
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 ) ;
263269
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 ) ;
267274
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 ) ;
271279 } ) ;
272280 } ) ;
273281
0 commit comments