@@ -12,23 +12,30 @@ describe('remote-input', function() {
12
12
} )
13
13
14
14
describe ( 'after tree insertion' , function ( ) {
15
+ let remoteInput
16
+ let input
17
+ let results
18
+
15
19
beforeEach ( function ( ) {
16
20
document . body . innerHTML = `
17
21
<remote-input aria-owns="results" src="/results">
18
22
<input>
19
23
</remote-input>
20
24
<div id="results"></div>
21
25
`
26
+ remoteInput = document . querySelector ( 'remote-input' )
27
+ input = remoteInput . querySelector ( 'input' )
28
+ results = document . querySelector ( '#results' )
22
29
} )
23
30
24
31
afterEach ( function ( ) {
25
32
document . body . innerHTML = ''
33
+ remoteInput = null
34
+ input = null
35
+ results = null
26
36
} )
27
37
28
38
it ( 'emits network events in order' , async function ( ) {
29
- const remoteInput = document . querySelector ( 'remote-input' )
30
- const input = document . querySelector ( 'input' )
31
-
32
39
const events = [ ]
33
40
const track = event => events . push ( event . type )
34
41
@@ -49,9 +56,6 @@ describe('remote-input', function() {
49
56
} )
50
57
51
58
it ( 'loads content' , async function ( ) {
52
- const remoteInput = document . querySelector ( 'remote-input' )
53
- const input = document . querySelector ( 'input' )
54
- const results = document . querySelector ( '#results' )
55
59
assert . equal ( results . innerHTML , '' )
56
60
57
61
const success = once ( remoteInput , 'remote-input-success' )
@@ -66,9 +70,6 @@ describe('remote-input', function() {
66
70
} )
67
71
68
72
it ( 'handles not ok responses' , async function ( ) {
69
- const remoteInput = document . querySelector ( 'remote-input' )
70
- const input = document . querySelector ( 'input' )
71
- const results = document . querySelector ( '#results' )
72
73
remoteInput . src = '/500'
73
74
assert . equal ( results . innerHTML , '' )
74
75
@@ -85,9 +86,6 @@ describe('remote-input', function() {
85
86
} )
86
87
87
88
it ( 'handles network error' , async function ( ) {
88
- const remoteInput = document . querySelector ( 'remote-input' )
89
- const input = remoteInput . querySelector ( 'input' )
90
- const results = document . querySelector ( '#results' )
91
89
remoteInput . src = '/network-error'
92
90
assert . equal ( results . innerHTML , '' )
93
91
@@ -104,9 +102,6 @@ describe('remote-input', function() {
104
102
} )
105
103
106
104
it ( 'repects param attribute' , async function ( ) {
107
- const remoteInput = document . querySelector ( 'remote-input' )
108
- const input = document . querySelector ( 'input' )
109
- const results = document . querySelector ( '#results' )
110
105
remoteInput . setAttribute ( 'param' , 'robot' )
111
106
assert . equal ( results . innerHTML , '' )
112
107
@@ -120,10 +115,6 @@ describe('remote-input', function() {
120
115
} )
121
116
122
117
it ( 'loads content again after src is changed' , async function ( ) {
123
- const remoteInput = document . querySelector ( 'remote-input' )
124
- const input = document . querySelector ( 'input' )
125
- const results = document . querySelector ( '#results' )
126
-
127
118
const result1 = once ( remoteInput , 'remote-input-success' )
128
119
input . value = 'test'
129
120
input . focus ( )
0 commit comments