@@ -1329,6 +1329,42 @@ describe('gridstack', function() {
13291329 } ) ;
13301330 } ) ;
13311331
1332+ describe ( 'two grids' , function ( ) {
1333+ beforeEach ( function ( ) {
1334+ document . body . insertAdjacentHTML ( 'afterbegin' , gridstackHTML ) ;
1335+ document . body . insertAdjacentHTML ( 'afterbegin' , gridstackHTML ) ;
1336+ } ) ;
1337+ afterEach ( function ( ) {
1338+ document . body . removeChild ( document . getElementById ( 'gs-cont' ) ) ;
1339+ } ) ;
1340+ it ( 'should not remove incorrect child' , function ( ) {
1341+ let grids = GridStack . initAll ( ) ;
1342+ expect ( grids . length ) . toBe ( 2 ) ;
1343+ expect ( grids [ 0 ] . engine . nodes . length ) . toBe ( 2 ) ;
1344+ expect ( grids [ 1 ] . engine . nodes . length ) . toBe ( 2 ) ;
1345+ // should do nothing
1346+ grids [ 0 ] . removeWidget ( grids [ 1 ] . engine . nodes [ 0 ] . el ) ;
1347+ expect ( grids [ 0 ] . engine . nodes . length ) . toBe ( 2 ) ;
1348+ expect ( grids [ 0 ] . el . children . length ) . toBe ( 2 ) ;
1349+ expect ( grids [ 1 ] . engine . nodes . length ) . toBe ( 2 ) ;
1350+ expect ( grids [ 1 ] . el . children . length ) . toBe ( 2 ) ;
1351+ // should empty with no errors
1352+ grids [ 1 ] . removeAll ( ) ;
1353+ expect ( grids [ 0 ] . engine . nodes . length ) . toBe ( 2 ) ;
1354+ expect ( grids [ 0 ] . el . children . length ) . toBe ( 2 ) ;
1355+ expect ( grids [ 1 ] . engine . nodes . length ) . toBe ( 0 ) ;
1356+ expect ( grids [ 1 ] . el . children . length ) . toBe ( 0 ) ;
1357+ } ) ;
1358+ it ( 'should remove 1 child' , function ( ) {
1359+ let grids = GridStack . initAll ( ) ;
1360+ grids [ 1 ] . removeWidget ( grids [ 1 ] . engine . nodes [ 0 ] . el ) ;
1361+ expect ( grids [ 0 ] . engine . nodes . length ) . toBe ( 2 ) ;
1362+ expect ( grids [ 0 ] . el . children . length ) . toBe ( 2 ) ;
1363+ expect ( grids [ 1 ] . engine . nodes . length ) . toBe ( 1 ) ;
1364+ expect ( grids [ 1 ] . el . children . length ) . toBe ( 1 ) ;
1365+ } ) ;
1366+ } ) ;
1367+
13321368 describe ( 'grid.compact' , function ( ) {
13331369 beforeEach ( function ( ) {
13341370 document . body . insertAdjacentHTML ( 'afterbegin' , gridstackHTML ) ;
0 commit comments