mirror of
https://github.com/matrix-org/matrix-hookshot.git
synced 2025-03-10 21:19:13 +00:00

* Split out queue and cache config * Update usages of cache config, * Update default * Cleanup * Make queue optional. * config updates. * changelog * update spec config * Update tests * tweak import * Update default config. * fixup test * Update config.sample.yml Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> Signed-off-by: Will Hunt <will@half-shot.uk> * Update encryption.md Signed-off-by: Will Hunt <will@half-shot.uk> * Clear up worker config Signed-off-by: Will Hunt <will@half-shot.uk> * Update src/config/Config.ts Co-authored-by: Andrew Ferrazzutti <andrewf@element.io> Signed-off-by: Will Hunt <will@half-shot.uk> * update helm config * lint * fix meta * tidy tidy * revert logging change * lint rust --------- Signed-off-by: Will Hunt <will@half-shot.uk> Co-authored-by: Andrew Ferrazzutti <andrewf@element.io>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
import { expect } from "chai";
|
|
import { createMessageQueue } from "../src/MessageQueue/MessageQueue";
|
|
|
|
const mq = createMessageQueue();
|
|
|
|
describe("MessageQueueTest", () => {
|
|
describe("LocalMq", () => {
|
|
it("should be able to push an event, and listen for it", (done) => {
|
|
mq.subscribe("fakeevent");
|
|
mq.on("fakeevent", (msg) => {
|
|
expect(msg).to.deep.equal({
|
|
sender: "foo",
|
|
eventName: "fakeevent",
|
|
messageId: "foooo",
|
|
data: 51,
|
|
});
|
|
done();
|
|
});
|
|
mq.push<number>({
|
|
sender: "foo",
|
|
eventName: "fakeevent",
|
|
messageId: "foooo",
|
|
data: 51,
|
|
});
|
|
});
|
|
it("should be able to push an event, and respond to it", async () => {
|
|
mq.subscribe("fakeevent2");
|
|
mq.subscribe("response.fakeevent2");
|
|
mq.on("fakeevent2", async (msg) => {
|
|
expect(msg).to.deep.equal({
|
|
sender: "foo",
|
|
eventName: "fakeevent2",
|
|
messageId: "foooo",
|
|
data: 49,
|
|
});
|
|
await mq.push<string>({
|
|
sender: "foo",
|
|
eventName: "response.fakeevent2",
|
|
messageId: "foooo",
|
|
data: "worked",
|
|
});
|
|
});
|
|
const response = await mq.pushWait<number, string>({
|
|
sender: "foo",
|
|
eventName: "fakeevent2",
|
|
messageId: "foooo",
|
|
data: 49,
|
|
});
|
|
expect(response).to.equal("worked");
|
|
});
|
|
});
|
|
});
|