1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 02:44:45 +00:00

test(packages/stdlib): add pubsub edge case check

This commit is contained in:
2024-10-01 07:13:09 +07:00
parent 307ec29787
commit 61c699381b

View File

@@ -92,4 +92,15 @@ describe('pubsub', () => {
expect(result).toBe(false);
});
it('calls listener only once when the same function is registered multiple times', () => {
const listener = vi.fn();
eventBus.on('event1', listener);
eventBus.on('event1', listener);
eventBus.on('event1', listener);
eventBus.emit('event1', 'Hello');
expect(listener).toHaveBeenCalledTimes(1);
});
});