Skip to content

Commit b937a7e

Browse files
dgrahammuan
andcommitted
Test event dispatch order
Co-authored-by: Mu-An Chiou <[email protected]>
1 parent 6698b4b commit b937a7e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,29 @@ describe('remote-input', function() {
2525
document.body.innerHTML = ''
2626
})
2727

28+
it('emits network events in order', async function() {
29+
const remoteInput = document.querySelector('remote-input')
30+
const input = document.querySelector('input')
31+
32+
const events = []
33+
const track = event => events.push(event.type)
34+
35+
remoteInput.addEventListener('loadstart', track)
36+
remoteInput.addEventListener('load', track)
37+
remoteInput.addEventListener('loadend', track)
38+
39+
const completed = Promise.all([
40+
once(remoteInput, 'loadstart'),
41+
once(remoteInput, 'load'),
42+
once(remoteInput, 'loadend')
43+
])
44+
input.value = 'test'
45+
input.focus()
46+
await completed
47+
48+
assert.deepEqual(['loadstart', 'load', 'loadend'], events)
49+
})
50+
2851
it('loads content', async function() {
2952
const remoteInput = document.querySelector('remote-input')
3053
const input = document.querySelector('input')

0 commit comments

Comments
 (0)