Code coverage

This commit is contained in:
Cadence Ember 2024-08-28 13:01:59 +12:00
commit 65de8aaf98
4 changed files with 128 additions and 1 deletions

View file

@ -772,6 +772,38 @@ test("event2message: code blocks are uploaded as attachments instead if they con
)
})
test("event2message: code blocks are uploaded as attachments instead if they contain incompatible backticks (default to txt file extension)", async t => {
t.deepEqual(
await eventToMessage({
type: "m.room.message",
sender: "@cadence:cadence.moe",
content: {
msgtype: "m.text",
body: "wrong body",
format: "org.matrix.custom.html",
formatted_body: 'So if you run code like this<pre><code>System.out.println("```");</code></pre>it should print a markdown formatted code block'
},
event_id: "$pGkWQuGVmrPNByrFELxhzI6MCBgJecr5I2J3z88Gc2s",
room_id: "!BpMdOUkWWhFxmTrENV:cadence.moe"
}),
{
ensureJoined: [],
messagesToDelete: [],
messagesToEdit: [],
messagesToSend: [{
username: "cadence [they]",
content: "So if you run code like this `[inline_code.txt]` it should print a markdown formatted code block",
attachments: [{id: "0", filename: "inline_code.txt"}],
pendingFiles: [{name: "inline_code.txt", buffer: Buffer.from('System.out.println("```");')}],
avatar_url: undefined,
allowed_mentions: {
parse: ["users", "roles"]
}
}]
}
)
})
test("event2message: characters are encoded properly in code blocks", async t => {
t.deepEqual(
await eventToMessage({