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

* Ensure connection state always explicitly states all keys, even if some are undefined. * changelog * Fix type * fix test types * Add support for E2E testing * Add CI job for e2e test * Ensure integration test only runs when regular tests complete * Add homerunner image * Disallow concurrent runs * Add concurrency to other expensive steps * changelog * Fix mq test * Cache rust deps * Drop only * Use a shared key
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import { expect } from "chai";
|
|
import { createMessageQueue } from "../src/MessageQueue/MessageQueue";
|
|
|
|
const mq = createMessageQueue({
|
|
monolithic: true,
|
|
});
|
|
|
|
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");
|
|
});
|
|
});
|
|
});
|