nestjs-typed-events
Version:
Typesafe NestJS event emitter module
26 lines • 980 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const contract_1 = require("./contract");
const zod_1 = require("zod");
const eventemitter2_1 = require("eventemitter2");
const emitter_1 = require("./emitter");
describe(emitter_1.TypedEventEmitter.name, () => {
const contract = contract_1.EventContractBuilder.create()
.required('test.event', zod_1.z.object({
foo: zod_1.z.string(),
}))
.required('other.event', zod_1.z.string())
.build();
describe('typing', () => {
it('should enforce correct args for event', () => {
const emitter = new emitter_1.TypedEventEmitter(new eventemitter2_1.EventEmitter2());
emitter.emit('test.event', {
foo: 'bar',
});
emitter.emit('test.event', {});
emitter.emit('other.event', '');
emitter.emit('other.event', 1);
});
});
});
//# sourceMappingURL=emitter.spec.js.map