|
49 | 49 | document.body.removeChild(el); |
50 | 50 | }); |
51 | 51 |
|
52 | | - function verifyObserverOutput(nestingLevel, nested) { |
| 52 | + async function verifyObserverOutput(nestingLevel, nested) { |
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) { |
|
92 | 92 | assert.equal(el.$.compose.$.basic2.getAttribute('attrvalue'), '42'); |
93 | 93 | assert.equal(el.$.forward.$.compose.$.basic1.getAttribute('attrvalue'), '42'); |
94 | 94 | assert.equal(el.$.forward.$.compose.$.basic2.getAttribute('attrvalue'), '42'); |
| 95 | + assert.equal(el.$.pe.obj, nested.obj); |
95 | 96 | switch (nestingLevel) { |
96 | 97 | case 0: |
97 | 98 | assert.equal(el.nestedSubpathChanged.firstCall.args[0].path, 'nested'); |
|
104 | 105 | assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, nested.obj); |
105 | 106 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj'); |
106 | 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); |
107 | 111 | break; |
108 | 112 | case 1: |
109 | 113 | assert.equal(el.nestedSubpathChanged.firstCall.args[0].path, 'nested.obj'); |
|
116 | 120 | assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, nested.obj); |
117 | 121 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj'); |
118 | 122 | 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); |
119 | 126 | break; |
120 | 127 | case 2: |
121 | 128 | assert.equal(el.nestedSubpathChanged.firstCall.args[0].path, 'nested.obj.value'); |
|
128 | 135 | assert.equal(el.$.forward.objSubpathChanged.firstCall.args[0].value, 42); |
129 | 136 | assert.equal(el.$.forward.$.compose.objSubpathChanged.firstCall.args[0].path, 'obj.value'); |
130 | 137 | 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); |
131 | 143 | break; |
132 | 144 | } |
133 | 145 | } |
134 | 146 |
|
135 | | - test('downward data flow', function() { |
| 147 | + test('downward data flow', async function() { |
136 | 148 | // Do the thing |
137 | 149 | el.nested = { |
138 | 150 | obj: { |
139 | 151 | value: 42 |
140 | 152 | } |
141 | 153 | }; |
142 | 154 | // Verify |
143 | | - verifyObserverOutput(0, el.nested); |
| 155 | + await verifyObserverOutput(0, el.nested); |
144 | 156 | }); |
145 | 157 |
|
146 | | - test('notification from basic element property change', function() { |
| 158 | + test('notification from basic element property change', async function() { |
147 | 159 | // Setup |
148 | 160 | el.nested = { |
149 | 161 | obj: { |
|
154 | 166 | // Do the thing |
155 | 167 | el.$.basic.notifyingValue = 42; |
156 | 168 | // Verify |
157 | | - verifyObserverOutput(2, el.nested); |
| 169 | + await verifyObserverOutput(2, el.nested); |
158 | 170 | }); |
159 | 171 |
|
160 | | - test('notification from composed element property change', function() { |
| 172 | + test('notification from composed element property change', async function() { |
161 | 173 | // Setup |
162 | 174 | el.nested = { |
163 | 175 | obj: { |
|
168 | 180 | // Do the thing |
169 | 181 | el.$.compose.$.basic1.notifyingValue = 42; |
170 | 182 | // Verify |
171 | | - verifyObserverOutput(2, el.nested); |
| 183 | + await verifyObserverOutput(2, el.nested); |
172 | 184 | }); |
173 | 185 |
|
174 | | - test('notification from forward\'s composed element property change', function() { |
| 186 | + test('notification from forward\'s composed element property change', async function() { |
175 | 187 | // Setup |
176 | 188 | el.nested = { |
177 | 189 | obj: { |
|
182 | 194 | // Do the thing |
183 | 195 | el.$.forward.$.compose.$.basic1.notifyingValue = 42; |
184 | 196 | // Verify |
185 | | - verifyObserverOutput(2, el.nested); |
| 197 | + await verifyObserverOutput(2, el.nested); |
186 | 198 | }); |
187 | 199 |
|
188 | | - test('notification from set in top element', function() { |
| 200 | + test('notification from set in top element', async function() { |
189 | 201 | // Setup |
190 | 202 | el.nested = { |
191 | 203 | obj: { |
|
196 | 208 | // Do the thing |
197 | 209 | el.set('nested.obj.value', 42); |
198 | 210 | // Verify |
199 | | - verifyObserverOutput(2, el.nested); |
| 211 | + await verifyObserverOutput(2, el.nested); |
200 | 212 | }); |
201 | 213 |
|
202 | | - test('notification from set in composed element', function() { |
| 214 | + test('notification from set in composed element', async function() { |
203 | 215 | // Setup |
204 | 216 | el.nested = { |
205 | 217 | obj: { |
|
210 | 222 | // Do the thing |
211 | 223 | el.$.compose.set('obj.value', 42); |
212 | 224 | // Verify |
213 | | - verifyObserverOutput(2, el.nested); |
| 225 | + await verifyObserverOutput(2, el.nested); |
214 | 226 | }); |
215 | 227 |
|
216 | | - test('notification from set in forward element', function() { |
| 228 | + test('notification from set in forward element', async function() { |
217 | 229 | // Setup |
218 | 230 | el.nested = { |
219 | 231 | obj: { |
|
224 | 236 | // Do the thing |
225 | 237 | el.$.forward.set('obj.value', 42); |
226 | 238 | // Verify |
227 | | - verifyObserverOutput(2, el.nested); |
| 239 | + await verifyObserverOutput(2, el.nested); |
228 | 240 | }); |
229 | 241 |
|
230 | | - test('notification from set in forward\'s composed element', function() { |
| 242 | + test('notification from set in forward\'s composed element', async function() { |
231 | 243 | // Setup |
232 | 244 | el.nested = { |
233 | 245 | obj: { |
|
238 | 250 | // Do the thing |
239 | 251 | el.$.forward.$.compose.set('obj.value', 42); |
240 | 252 | // Verify |
241 | | - verifyObserverOutput(2, el.nested); |
| 253 | + await verifyObserverOutput(2, el.nested); |
242 | 254 | }); |
243 | 255 |
|
244 | | - test('notification from object change in compose element', function() { |
| 256 | + test('notification from object change in compose element', async function() { |
245 | 257 | // Setup |
246 | 258 | el.nested = { |
247 | 259 | obj: { |
|
254 | 266 | value: 42 |
255 | 267 | }; |
256 | 268 | // Verify |
257 | | - verifyObserverOutput(1, el.nested); |
| 269 | + await verifyObserverOutput(1, el.nested); |
258 | 270 | }); |
259 | 271 |
|
260 | | - test('notification from object change in forward element', function() { |
| 272 | + test('notification from object change in forward element', async function() { |
261 | 273 | // Setup |
262 | 274 | el.nested = { |
263 | 275 | obj: { |
|
270 | 282 | value: 42 |
271 | 283 | }; |
272 | 284 | // Verify |
273 | | - verifyObserverOutput(1, el.nested); |
| 285 | + await verifyObserverOutput(1, el.nested); |
274 | 286 | }); |
275 | 287 |
|
276 | | - test('notification from object change in forward\'s compose element', function() { |
| 288 | + test('notification from object change in forward\'s compose element', async function() { |
277 | 289 | // Setup |
278 | 290 | el.nested = { |
279 | 291 | obj: { |
|
287 | 299 | value: 42 |
288 | 300 | }; |
289 | 301 | // Verify |
290 | | - verifyObserverOutput(1, el.nested); |
| 302 | + await verifyObserverOutput(1, el.nested); |
291 | 303 | }); |
292 | 304 |
|
293 | 305 | test('cached paths get invalidated by object sets', function() { |
|
0 commit comments