@@ -899,14 +899,14 @@ describe('gridstack', function() {
899
899
900
900
} ) ;
901
901
902
- describe ( 'addWidget() with bad string value widget options ' , function ( ) {
902
+ describe ( 'addWidget()' , function ( ) {
903
903
beforeEach ( function ( ) {
904
904
document . body . insertAdjacentHTML ( 'afterbegin' , gridstackHTML ) ;
905
905
} ) ;
906
906
afterEach ( function ( ) {
907
907
document . body . removeChild ( document . getElementById ( 'gs-cont' ) ) ;
908
908
} ) ;
909
- it ( 'should use default' , function ( ) {
909
+ it ( 'bad string options should use default' , function ( ) {
910
910
var grid = GridStack . init ( ) ;
911
911
var widget = grid . addWidget ( widgetHTML , { x : 'foo' , y : null , width : 'bar' , height : '' } ) ;
912
912
var $widget = $ ( widget ) ;
@@ -915,23 +915,27 @@ describe('gridstack', function() {
915
915
expect ( parseInt ( $widget . attr ( 'data-gs-width' ) , 10 ) ) . toBe ( 1 ) ;
916
916
expect ( parseInt ( $widget . attr ( 'data-gs-height' ) , 10 ) ) . toBe ( 1 ) ;
917
917
} ) ;
918
- } ) ;
919
-
920
- describe ( 'addWidget with null options, ' , function ( ) {
921
- beforeEach ( function ( ) {
922
- document . body . insertAdjacentHTML ( 'afterbegin' , gridstackHTML ) ;
923
- } ) ;
924
- afterEach ( function ( ) {
925
- document . body . removeChild ( document . getElementById ( 'gs-cont' ) ) ;
926
- } ) ;
927
- it ( 'should clear x position' , function ( ) {
918
+ it ( 'null options should clear x position' , function ( ) {
928
919
var grid = GridStack . init ( { float : true } ) ;
929
920
var widgetHTML = '<div class="grid-stack-item" data-gs-x="9"><div class="grid-stack-item-content"></div></div>' ;
930
921
var widget = grid . addWidget ( widgetHTML , null , null , undefined ) ;
931
922
var $widget = $ ( widget ) ;
932
923
expect ( parseInt ( $widget . attr ( 'data-gs-x' ) , 10 ) ) . toBe ( 8 ) ;
933
924
expect ( parseInt ( $widget . attr ( 'data-gs-y' ) , 10 ) ) . toBe ( 0 ) ;
934
925
} ) ;
926
+ it ( 'width attr should be retained' , function ( ) { // #1276
927
+ var grid = GridStack . init ( { float : true } ) ;
928
+ var widgetHTML = '<div class="grid-stack-item" data-gs-width="3" data-gs-max-width="4" data-gs-id="foo"><div class="grid-stack-item-content"></div></div>' ;
929
+ var widget = grid . addWidget ( widgetHTML , 1 , 5 ) ;
930
+ var $widget = $ ( widget ) ;
931
+ expect ( parseInt ( $widget . attr ( 'data-gs-x' ) , 10 ) ) . toBe ( 1 ) ;
932
+ expect ( parseInt ( $widget . attr ( 'data-gs-y' ) , 10 ) ) . toBe ( 5 ) ;
933
+ expect ( parseInt ( $widget . attr ( 'data-gs-width' ) , 10 ) ) . toBe ( 3 ) ;
934
+ expect ( parseInt ( $widget . attr ( 'data-gs-max-width' ) , 10 ) ) . toBe ( 4 ) ;
935
+ expect ( parseInt ( $widget . attr ( 'data-gs-height' ) , 10 ) ) . toBe ( 1 ) ;
936
+ expect ( $widget . attr ( 'data-gs-id' ) ) . toBe ( 'foo' ) ;
937
+ } ) ;
938
+
935
939
} ) ;
936
940
937
941
describe ( 'method float()' , function ( ) {
0 commit comments