From 6a222dc4d27dab1ff053c451fd7b55bfd1aad36a Mon Sep 17 00:00:00 2001 From: Jared Wray Date: Tue, 15 Oct 2024 12:20:03 -0700 Subject: [PATCH] test for once --- test/eventified.test.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/eventified.test.ts b/test/eventified.test.ts index 3117003..a694711 100644 --- a/test/eventified.test.ts +++ b/test/eventified.test.ts @@ -134,4 +134,18 @@ describe('Eventified', () => { t.expect(emitter.listeners('test-event')).toEqual([listener]); }); + + test('emit event only once with once method', t => { + const emitter = new Eventified(); + let dataReceived = 0; + + emitter.once('test-event', () => { + dataReceived++; + }); + + emitter.emit('test-event'); + emitter.emit('test-event'); + + t.expect(dataReceived).toBe(1); + }); });