diff --git a/packages/@ember/-internals/glimmer/tests/integration/modifiers/on-test.js b/packages/@ember/-internals/glimmer/tests/integration/modifiers/on-test.js index 7d9556715a8..17a8b1f83e4 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/modifiers/on-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/modifiers/on-test.js @@ -267,6 +267,37 @@ moduleFor( this.assertCounts({ adds: 1, removes: 1 }); } + + [`@test can be set or unset dynamically multiple times on an element`](assert) { + let wasCalled = false; + let toggle = () => (wasCalled = !wasCalled); + + this.render( + '', + { + bindClick: false, + toggle, + on, + } + ); + + this.$('button').click(); + assert.false(wasCalled); + + runTask(() => this.context.set('bindClick', true)); + + this.$('button').click(); + assert.true(wasCalled); + + wasCalled = false; + runTask(() => this.context.set('bindClick', false)); + this.$('button').click(); + assert.false(wasCalled); + + runTask(() => this.context.set('bindClick', true)); + this.$('button').click(); + assert.true(wasCalled); + } } );