Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
subscriptions = [{
id: "step.one" + timestamp ,
event: "test.emit",
emit: {
topic: "next",
event: "test.emit.received"
}
}];
service = broker.createService(Subscriber, Object.assign({ settings: { brokers: ["192.168.2.124:9092"], subscriptions: subscriptions } }));
await broker.start();
let content = {
meta: opts.meta,
event: "test.emit",
payload: { msg: "say hello to the world" },
};
producers.forEach(producer => { producer.fail = true; });
mock.__emittedEventReset();
try {
await mock.__emit("events", 10, content);
} catch (err) {
expect(err.message).toBe("simulated fail of producer.send");
}
let emittedEvent = mock.__emittedEvent();
expect(emittedEvent).toEqual(null);
});