|
1 | 1 | import { |
| 2 | + aTimeout, |
2 | 3 | elementUpdated, |
3 | 4 | expect, |
4 | 5 | fixture, |
@@ -257,48 +258,26 @@ describe('Icon broadcast service', () => { |
257 | 258 | it('when multiple broadcast services are initialized they should not send sync events to each other.', async () => { |
258 | 259 | const collections = createIconDefaultMap<string, SvgIcon>(); |
259 | 260 | const references = createIconDefaultMap<string, IconMeta>(); |
260 | | - |
261 | | - const evt1 = []; |
| 261 | + // 2 new broadcasts |
262 | 262 | const broadcast1 = new IconsStateBroadcast(collections, references); |
263 | | - (broadcast1 as any).channel.addEventListener( |
264 | | - 'message', |
265 | | - (e: MessageEvent<BroadcastIconsChangeMessage>) => { |
266 | | - evt1.push(e); |
267 | | - } |
268 | | - ); |
269 | | - |
270 | | - const evt2 = []; |
271 | 263 | const broadcast2 = new IconsStateBroadcast(collections, references); |
272 | | - (broadcast2 as any).channel.addEventListener( |
273 | | - 'message', |
274 | | - (e: MessageEvent<BroadcastIconsChangeMessage>) => { |
275 | | - evt2.push(e); |
276 | | - } |
277 | | - ); |
278 | | - |
279 | | - const evt3 = []; |
280 | | - const broadcast3 = new IconsStateBroadcast(collections, references); |
281 | | - (broadcast3 as any).channel.addEventListener( |
282 | | - 'message', |
283 | | - (e: MessageEvent<BroadcastIconsChangeMessage>) => { |
284 | | - evt3.push(e); |
285 | | - } |
286 | | - ); |
| 264 | + // 1 global one, initialized when you get the icon registry first time. |
| 265 | + const iconReg = getIconRegistry(); |
| 266 | + // total - 3 services now. |
287 | 267 |
|
288 | 268 | // a peer is requesting a state sync |
289 | 269 | channel.postMessage({ actionType: ActionType.SyncState }); |
290 | | - await nextFrame(); |
| 270 | + await aTimeout(20); |
291 | 271 |
|
292 | | - // all icon broadcasts must respond once on the channel with their state |
293 | | - // so 1 event from the peer + 1 response event with state per broadcast service. |
294 | | - expect(evt1.length).to.equal(4); |
295 | | - expect(evt2.length).to.equal(4); |
296 | | - expect(evt3.length).to.equal(4); |
| 272 | + // all icon broadcasts must respond with their state |
| 273 | + // 2 from broadcast service + 1 from global. |
| 274 | + expect(events.length).to.equal(3); |
297 | 275 |
|
298 | 276 | // dispose of mock services. |
299 | | - (broadcast1 as any).dispose(); |
300 | | - (broadcast2 as any).dispose(); |
301 | | - (broadcast3 as any).dispose(); |
| 277 | + // biome-ignore lint/complexity/useLiteralKeys: private access escape |
| 278 | + broadcast1['dispose'](); |
| 279 | + // biome-ignore lint/complexity/useLiteralKeys: private access escape |
| 280 | + broadcast2['dispose'](); |
302 | 281 | }); |
303 | 282 | }); |
304 | 283 |
|
|
0 commit comments