Skip to content

Commit 344a118

Browse files
committed
test: add bind test that asserts deep children are bound
1 parent 10eef6c commit 344a118

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

test/bind.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,24 @@ describe('bind', () => {
206206
expect(instance.foo).to.have.been.called.exactly(0)
207207
})
208208
})
209+
210+
it('re-binds actions deeply in the HTML', async function () {
211+
const instance = document.createElement('bind-test-element')
212+
chai.spy.on(instance, 'foo')
213+
root.appendChild(instance)
214+
listenForBind(root)
215+
instance.innerHTML = `
216+
<div>
217+
<div>
218+
<button data-action="click:bind-test-element#foo">
219+
</div>
220+
</div>
221+
`
222+
// We need to wait for a couple of frames after injecting the HTML into to
223+
// controller so that the actions have been bound to the controller.
224+
await waitForNextAnimationFrame()
225+
await waitForNextAnimationFrame()
226+
instance.querySelector('button').click()
227+
expect(instance.foo).to.have.been.called.exactly(1)
228+
})
209229
})

0 commit comments

Comments
 (0)