Skip to content

Commit

Permalink
spec/integ/matrix-to-irc: add test for self-reply
Browse files Browse the repository at this point in the history
Signed-off-by: Ferass El Hafidi <[email protected]>
  • Loading branch information
Ferass El Hafidi committed Aug 6, 2024
1 parent 6f8aaf1 commit 6d92beb
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions spec/integ/matrix-to-irc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,52 @@ describe("Matrix-to-IRC message bridging", function() {
});
});

it("should bridge matrix replies to self as self-replies", async () => {
// Trigger an original event
await env.mockAppService._trigger("type:m.room.message", {
content: {
body: "This is the real message",
msgtype: "m.text"
},
room_id: roomMapping.roomId,
sender: repliesUser.id,
event_id: "$original:bar.com",
origin_server_ts: Date.now(),
type: "m.room.message"
});
const p = env.ircMock._whenClient(roomMapping.server, repliesUser.nick, "say",
(client, channel, text) => {
expect(client.nick).toEqual(repliesUser.nick);
expect(client.addr).toEqual(roomMapping.server);
expect(channel).toEqual(roomMapping.channel);
expect(text).toEqual(`<${repliesUser.nick}> This is the real message\nReply Text`);
}
);
const formatted_body = constructHTMLReply(
"This is the fake message",
"@somedude:bar.com",
"Reply text"
);
await env.mockAppService._trigger("type:m.room.message", {
content: {
body: "> <@somedude:bar.com> This is the fake message\n\nReply Text",
formatted_body,
format: "org.matrix.custom.html",
msgtype: "m.text",
"m.relates_to": {
"m.in_reply_to": {
"event_id": "$original:bar.com"
}
},
},
sender: repliesUser.id,
room_id: roomMapping.roomId,
origin_server_ts: Date.now(),
type: "m.room.message"
});
await p;
});

it("should bridge rapid matrix replies as short replies", async () => {
// Trigger an original event
await env.mockAppService._trigger("type:m.room.message", {
Expand Down

0 comments on commit 6d92beb

Please sign in to comment.