Skip to content

Commit

Permalink
test for once
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredwray committed Oct 15, 2024
1 parent d565a83 commit 6a222dc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/eventified.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});

0 comments on commit 6a222dc

Please sign in to comment.