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

* Update dependencies * Node 22 is now the new minimum version. * changelog. * Begin porting eslint to new config format. * Make linter happy. * Update reqwest to fix SSL issue? * Fix test types * quick check on ubuntu LTS 24.04 * Change cache key * update rust action * revert mocha due to esminess * Remove the only usage of pqueue * Use babel for TS transformations to get around ESM import bug. * Dependency bundle upgrade * Drop babel, not actually used. * lint * lint * update default config (mostly sections moving around)
54 lines
1.7 KiB
TypeScript
54 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");
|
|
});
|
|
});
|
|
});
|