Skip to content

Commit d5e1962

Browse files
committed
chore(*): Update test based on feedback.
1 parent 8190531 commit d5e1962

File tree

1 file changed

+13
-34
lines changed

1 file changed

+13
-34
lines changed

src/components/icon/icon.spec.ts

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
aTimeout,
23
elementUpdated,
34
expect,
45
fixture,
@@ -257,48 +258,26 @@ describe('Icon broadcast service', () => {
257258
it('when multiple broadcast services are initialized they should not send sync events to each other.', async () => {
258259
const collections = createIconDefaultMap<string, SvgIcon>();
259260
const references = createIconDefaultMap<string, IconMeta>();
260-
261-
const evt1 = [];
261+
// 2 new broadcasts
262262
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 = [];
271263
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.
287267

288268
// a peer is requesting a state sync
289269
channel.postMessage({ actionType: ActionType.SyncState });
290-
await nextFrame();
270+
await aTimeout(20);
291271

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);
297275

298276
// 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']();
302281
});
303282
});
304283

0 commit comments

Comments
 (0)