@@ -48,8 +48,7 @@ describe('remote-input', function() {
4848 once ( remoteInput , 'load' ) ,
4949 once ( remoteInput , 'loadend' )
5050 ] )
51- input . value = 'test'
52- input . focus ( )
51+ changeValue ( input , 'test' )
5352 await completed
5453
5554 assert . deepEqual ( [ 'loadstart' , 'load' , 'loadend' ] , events )
@@ -61,8 +60,7 @@ describe('remote-input', function() {
6160 const success = once ( remoteInput , 'remote-input-success' )
6261 const loadend = once ( remoteInput , 'loadend' )
6362
64- input . value = 'test'
65- input . focus ( )
63+ changeValue ( input , 'test' )
6664
6765 await success
6866 await loadend
@@ -76,8 +74,7 @@ describe('remote-input', function() {
7674 const error = once ( remoteInput , 'remote-input-error' )
7775 const loadend = once ( remoteInput , 'loadend' )
7876
79- input . value = 'test'
80- input . focus ( )
77+ changeValue ( input , 'test' )
8178
8279 await loadend
8380 await error
@@ -91,8 +88,7 @@ describe('remote-input', function() {
9188
9289 const result = once ( remoteInput , 'error' )
9390
94- input . value = 'test'
95- input . focus ( )
91+ changeValue ( input , 'test' )
9692 assert . ok ( remoteInput . hasAttribute ( 'loading' ) , 'loading attribute should have been added' )
9793
9894 await result
@@ -107,17 +103,15 @@ describe('remote-input', function() {
107103
108104 const result = once ( remoteInput , 'remote-input-success' )
109105
110- input . value = 'test'
111- input . focus ( )
106+ changeValue ( input , 'test' )
112107
113108 await result
114109 assert . equal ( results . querySelector ( 'ol' ) . getAttribute ( 'data-src' ) , '/results?robot=test' )
115110 } )
116111
117112 it ( 'loads content again after src is changed' , async function ( ) {
118113 const result1 = once ( remoteInput , 'remote-input-success' )
119- input . value = 'test'
120- input . focus ( )
114+ changeValue ( input , 'test' )
121115
122116 await result1
123117 assert . equal ( results . querySelector ( 'ol' ) . getAttribute ( 'data-src' ) , '/results?q=test' )
@@ -131,6 +125,11 @@ describe('remote-input', function() {
131125 } )
132126} )
133127
128+ function changeValue ( input , value ) {
129+ input . value = value
130+ input . dispatchEvent ( new Event ( 'change' ) )
131+ }
132+
134133function nextTick ( ) {
135134 return Promise . resolve ( )
136135}
0 commit comments