@@ -145,8 +145,7 @@ module('Integration | Component | grid stack', function (hooks) {
145145 } ) ;
146146
147147 test ( 'onChange, onAdded, onRemove actions' , async function ( assert ) {
148- // onAdded should run twice, onChange once, onRemoved twice
149- assert . expect ( 15 ) ;
148+ assert . expect ( 12 ) ;
150149
151150 this . set ( 'items' , A ( [ 1 ] ) ) ;
152151
@@ -303,4 +302,37 @@ module('Integration | Component | grid stack', function (hooks) {
303302 . dom ( `[data-id="3"]` )
304303 . hasAttribute ( 'gs-y' , '2' , 'Updating a grid-stack-item moves conflicting items to a different row' ) ;
305304 } ) ;
305+
306+ test ( 'do not fire `onChange` or `onRemoved` during teardown' , async function ( assert ) {
307+ assert . expect ( 1 ) ;
308+
309+ this . set ( 'shouldRender' , true ) ;
310+ this . set ( 'items' , [
311+ { id : 0 , options : { x : 0 , y : 0 , w : 5 , h : 1 } } ,
312+ { id : 1 , options : { x : 6 , y : 0 , w : 3 , h : 1 } } ,
313+ { id : 2 , options : { x : 0 , y : 1 , w : 4 , h : 1 } } ,
314+ { id : 3 , options : { x : 6 , y : 1 , w : 2 , h : 1 } } ,
315+ ] ) ;
316+
317+ this . onChange = ( ) => assert . notOk ( true , '`onChange` should not fire on teardown' ) ;
318+ this . onRemoved = ( ) => assert . notOk ( true , '`onRemoved` should not fire on teardown' ) ;
319+
320+ await render ( hbs `
321+ {{#if this.shouldRender}}
322+ <GridStack
323+ onChange={{this.onChange}}
324+ onRemoved={{this.onChange}}
325+ >
326+ {{#each this.items as |item|}}
327+ <GridStackItem data-id={{item.id}} @options={{item.options}}>
328+ {{item.id}}
329+ </GridStackItem>
330+ {{/each}}
331+ </GridStack>
332+ {{/if}}
333+ ` ) ;
334+
335+ this . set ( 'shouldRender' , false ) ;
336+ assert . ok ( true , 'all is good' ) ;
337+ } ) ;
306338} ) ;
0 commit comments