Initial Commit
This commit is contained in:
19
test/events/EventEmitter.test.ts
Normal file
19
test/events/EventEmitter.test.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import {afterAll, beforeEach, describe, expect, it, mock} from 'bun:test';
|
||||
import {EventEmitter} from '../../src/events';
|
||||
|
||||
describe(`When emitting an event`, () => {
|
||||
const eventEmitter: EventEmitter<string> = new EventEmitter<string>();
|
||||
|
||||
describe(`Given a callback is subscribed`, () => {
|
||||
const mockListener = mock(() => undefined);
|
||||
const subscription = eventEmitter.subscribe(mockListener);
|
||||
|
||||
describe(`Given an event is emitted`, () => {
|
||||
beforeEach(() => eventEmitter.emit('mock event'));
|
||||
|
||||
it(`notifies the callback with the event`, () => expect(mockListener).toHaveBeenCalled());
|
||||
});
|
||||
|
||||
afterAll(() => subscription.dispose());
|
||||
});
|
||||
});
|
||||
3
test/events/EventPublisher.test.ts
Normal file
3
test/events/EventPublisher.test.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import {describe} from 'bun:test';
|
||||
|
||||
describe.todo(`When publishing events`);
|
||||
Reference in New Issue
Block a user