|
49 | 49 | document.body.removeChild(el); |
50 | 50 | }); |
51 | 51 |
|
52 | | - async function verifyObserverOutput(nestingLevel, nested) { |
| 52 | + function verifyObserverOutput(nestingLevel, nested, done) { |
53 | 53 | assert.equal(el.computed, '[' + nested.obj.value + ']'); |
54 | 54 | assert.equal(el.nestedChanged.callCount, nestingLevel == 0 ? 1 : 0); |
55 | 55 | if (nestingLevel == 0) { |
|
105 | 105 | assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, nested.obj); |
106 | 106 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj'); |
107 | 107 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].value, nested.obj); |
108 | | - await Promise.resolve(); // x-pe uses async PropertiesChanged |
109 | | - assert.equal(el.$.pe._propertiesChanged.callCount, 1); |
110 | | - assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj); |
| 108 | + // x-pe uses async PropertiesChanged |
| 109 | + Promise.resolve().then(() => { |
| 110 | + assert.equal(el.$.pe._propertiesChanged.callCount, 1); |
| 111 | + assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj); |
| 112 | + done(); |
| 113 | + }); |
111 | 114 | break; |
112 | 115 | case 1: |
113 | 116 | assert.equal(el.nestedSubpathChanged.firstCall.args[0].path, 'nested.obj'); |
|
120 | 123 | assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, nested.obj); |
121 | 124 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj'); |
122 | 125 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].value, nested.obj); |
123 | | - await Promise.resolve(); // x-pe uses async PropertiesChanged |
124 | | - assert.equal(el.$.pe._propertiesChanged.callCount, 1); |
125 | | - assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj); |
| 126 | + // x-pe uses async PropertiesChanged |
| 127 | + Promise.resolve().then(() => { |
| 128 | + assert.equal(el.$.pe._propertiesChanged.callCount, 1); |
| 129 | + assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj); |
| 130 | + done(); |
| 131 | + }); |
126 | 132 | break; |
127 | 133 | case 2: |
128 | 134 | assert.equal(el.nestedSubpathChanged.firstCall.args[0].path, 'nested.obj.value'); |
|
135 | 141 | assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, 42); |
136 | 142 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj.value'); |
137 | 143 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].value, 42); |
138 | | - await Promise.resolve(); // x-pe uses async PropertiesChanged |
139 | | - // Note the PropertiesMixin element only sees a deep set to 'nested.obj.value' |
140 | | - // because it overrides _shouldPropertyChange to allow object re-sets through |
141 | | - assert.equal(el.$.pe._propertiesChanged.callCount, 1); |
142 | | - assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj); |
| 144 | + // x-pe uses async PropertiesChanged |
| 145 | + Promise.resolve().then(() => { |
| 146 | + // Note the PropertiesMixin element only sees a deep set to 'nested.obj.value' |
| 147 | + // because it overrides _shouldPropertyChange to allow object re-sets through |
| 148 | + assert.equal(el.$.pe._propertiesChanged.callCount, 1); |
| 149 | + assert.equal(el.$.pe._propertiesChanged.firstCall.args[1].obj, nested.obj); |
| 150 | + done(); |
| 151 | + }); |
143 | 152 | break; |
144 | 153 | } |
145 | 154 | } |
146 | 155 |
|
147 | | - test('downward data flow', async function() { |
| 156 | + test('downward data flow', function(done) { |
148 | 157 | // Do the thing |
149 | 158 | el.nested = { |
150 | 159 | obj: { |
151 | 160 | value: 42 |
152 | 161 | } |
153 | 162 | }; |
154 | 163 | // Verify |
155 | | - await verifyObserverOutput(0, el.nested); |
| 164 | + verifyObserverOutput(0, el.nested, done); |
156 | 165 | }); |
157 | 166 |
|
158 | | - test('notification from basic element property change', async function() { |
| 167 | + test('notification from basic element property change', function(done) { |
159 | 168 | // Setup |
160 | 169 | el.nested = { |
161 | 170 | obj: { |
|
166 | 175 | // Do the thing |
167 | 176 | el.$.basic.notifyingValue = 42; |
168 | 177 | // Verify |
169 | | - await verifyObserverOutput(2, el.nested); |
| 178 | + verifyObserverOutput(2, el.nested, done); |
170 | 179 | }); |
171 | 180 |
|
172 | | - test('notification from composed element property change', async function() { |
| 181 | + test('notification from composed element property change', function(done) { |
173 | 182 | // Setup |
174 | 183 | el.nested = { |
175 | 184 | obj: { |
|
180 | 189 | // Do the thing |
181 | 190 | el.$.compose.$.basic1.notifyingValue = 42; |
182 | 191 | // Verify |
183 | | - await verifyObserverOutput(2, el.nested); |
| 192 | + verifyObserverOutput(2, el.nested, done); |
184 | 193 | }); |
185 | 194 |
|
186 | | - test('notification from forward\'s composed element property change', async function() { |
| 195 | + test('notification from forward\'s composed element property change', function(done) { |
187 | 196 | // Setup |
188 | 197 | el.nested = { |
189 | 198 | obj: { |
|
194 | 203 | // Do the thing |
195 | 204 | el.$.forward.$.compose.$.basic1.notifyingValue = 42; |
196 | 205 | // Verify |
197 | | - await verifyObserverOutput(2, el.nested); |
| 206 | + verifyObserverOutput(2, el.nested, done); |
198 | 207 | }); |
199 | 208 |
|
200 | | - test('notification from set in top element', async function() { |
| 209 | + test('notification from set in top element', function(done) { |
201 | 210 | // Setup |
202 | 211 | el.nested = { |
203 | 212 | obj: { |
|
208 | 217 | // Do the thing |
209 | 218 | el.set('nested.obj.value', 42); |
210 | 219 | // Verify |
211 | | - await verifyObserverOutput(2, el.nested); |
| 220 | + verifyObserverOutput(2, el.nested, done); |
212 | 221 | }); |
213 | 222 |
|
214 | | - test('notification from set in composed element', async function() { |
| 223 | + test('notification from set in composed element', function(done) { |
215 | 224 | // Setup |
216 | 225 | el.nested = { |
217 | 226 | obj: { |
|
222 | 231 | // Do the thing |
223 | 232 | el.$.compose.set('obj.value', 42); |
224 | 233 | // Verify |
225 | | - await verifyObserverOutput(2, el.nested); |
| 234 | + verifyObserverOutput(2, el.nested, done); |
226 | 235 | }); |
227 | 236 |
|
228 | | - test('notification from set in forward element', async function() { |
| 237 | + test('notification from set in forward element', function(done) { |
229 | 238 | // Setup |
230 | 239 | el.nested = { |
231 | 240 | obj: { |
|
236 | 245 | // Do the thing |
237 | 246 | el.$.forward.set('obj.value', 42); |
238 | 247 | // Verify |
239 | | - await verifyObserverOutput(2, el.nested); |
| 248 | + verifyObserverOutput(2, el.nested, done); |
240 | 249 | }); |
241 | 250 |
|
242 | | - test('notification from set in forward\'s composed element', async function() { |
| 251 | + test('notification from set in forward\'s composed element', function(done) { |
243 | 252 | // Setup |
244 | 253 | el.nested = { |
245 | 254 | obj: { |
|
250 | 259 | // Do the thing |
251 | 260 | el.$.forward.$.compose.set('obj.value', 42); |
252 | 261 | // Verify |
253 | | - await verifyObserverOutput(2, el.nested); |
| 262 | + verifyObserverOutput(2, el.nested, done); |
254 | 263 | }); |
255 | 264 |
|
256 | | - test('notification from object change in compose element', async function() { |
| 265 | + test('notification from object change in compose element', function(done) { |
257 | 266 | // Setup |
258 | 267 | el.nested = { |
259 | 268 | obj: { |
|
266 | 275 | value: 42 |
267 | 276 | }; |
268 | 277 | // Verify |
269 | | - await verifyObserverOutput(1, el.nested); |
| 278 | + verifyObserverOutput(1, el.nested, done); |
270 | 279 | }); |
271 | 280 |
|
272 | | - test('notification from object change in forward element', async function() { |
| 281 | + test('notification from object change in forward element', function(done) { |
273 | 282 | // Setup |
274 | 283 | el.nested = { |
275 | 284 | obj: { |
|
282 | 291 | value: 42 |
283 | 292 | }; |
284 | 293 | // Verify |
285 | | - await verifyObserverOutput(1, el.nested); |
| 294 | + verifyObserverOutput(1, el.nested, done); |
286 | 295 | }); |
287 | 296 |
|
288 | | - test('notification from object change in forward\'s compose element', async function() { |
| 297 | + test('notification from object change in forward\'s compose element', function(done) { |
289 | 298 | // Setup |
290 | 299 | el.nested = { |
291 | 300 | obj: { |
|
299 | 308 | value: 42 |
300 | 309 | }; |
301 | 310 | // Verify |
302 | | - await verifyObserverOutput(1, el.nested); |
| 311 | + verifyObserverOutput(1, el.nested, done); |
303 | 312 | }); |
304 | 313 |
|
305 | 314 | test('cached paths get invalidated by object sets', function() { |
|
0 commit comments