Skip to content

Commit 54a858c

Browse files
committed
Add test for escape event propagation
1 parent 287178e commit 54a858c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,18 @@ describe('details-menu element', function() {
121121
assert(!details.open, 'details toggles closed')
122122
})
123123

124+
it('allow propagation on escape if details is closed', function() {
125+
const details = document.querySelector('details')
126+
const summary = details.querySelector('summary')
127+
128+
document.addEventListener('keydown', event => {
129+
if (event.key === 'Escape') summary.textContent = 'Propagated'
130+
})
131+
132+
summary.dispatchEvent(new KeyboardEvent('keydown', {key: 'Escape', bubbles: true}))
133+
assert.equal(summary.textContent, 'Propagated')
134+
})
135+
124136
it('updates the button label with text', function() {
125137
const details = document.querySelector('details')
126138
const summary = details.querySelector('summary')

0 commit comments

Comments
 (0)