@@ -48,8 +48,7 @@ describe('remote-input', function() {
48
48
once ( remoteInput , 'load' ) ,
49
49
once ( remoteInput , 'loadend' )
50
50
] )
51
- input . value = 'test'
52
- input . focus ( )
51
+ changeValue ( input , 'test' )
53
52
await completed
54
53
55
54
assert . deepEqual ( [ 'loadstart' , 'load' , 'loadend' ] , events )
@@ -61,8 +60,7 @@ describe('remote-input', function() {
61
60
const success = once ( remoteInput , 'remote-input-success' )
62
61
const loadend = once ( remoteInput , 'loadend' )
63
62
64
- input . value = 'test'
65
- input . focus ( )
63
+ changeValue ( input , 'test' )
66
64
67
65
await success
68
66
await loadend
@@ -76,8 +74,7 @@ describe('remote-input', function() {
76
74
const error = once ( remoteInput , 'remote-input-error' )
77
75
const loadend = once ( remoteInput , 'loadend' )
78
76
79
- input . value = 'test'
80
- input . focus ( )
77
+ changeValue ( input , 'test' )
81
78
82
79
await loadend
83
80
await error
@@ -91,8 +88,7 @@ describe('remote-input', function() {
91
88
92
89
const result = once ( remoteInput , 'error' )
93
90
94
- input . value = 'test'
95
- input . focus ( )
91
+ changeValue ( input , 'test' )
96
92
assert . ok ( remoteInput . hasAttribute ( 'loading' ) , 'loading attribute should have been added' )
97
93
98
94
await result
@@ -107,17 +103,15 @@ describe('remote-input', function() {
107
103
108
104
const result = once ( remoteInput , 'remote-input-success' )
109
105
110
- input . value = 'test'
111
- input . focus ( )
106
+ changeValue ( input , 'test' )
112
107
113
108
await result
114
109
assert . equal ( results . querySelector ( 'ol' ) . getAttribute ( 'data-src' ) , '/results?robot=test' )
115
110
} )
116
111
117
112
it ( 'loads content again after src is changed' , async function ( ) {
118
113
const result1 = once ( remoteInput , 'remote-input-success' )
119
- input . value = 'test'
120
- input . focus ( )
114
+ changeValue ( input , 'test' )
121
115
122
116
await result1
123
117
assert . equal ( results . querySelector ( 'ol' ) . getAttribute ( 'data-src' ) , '/results?q=test' )
@@ -131,6 +125,11 @@ describe('remote-input', function() {
131
125
} )
132
126
} )
133
127
128
+ function changeValue ( input , value ) {
129
+ input . value = value
130
+ input . dispatchEvent ( new Event ( 'change' ) )
131
+ }
132
+
134
133
function nextTick ( ) {
135
134
return Promise . resolve ( )
136
135
}
0 commit comments