1
0
Fork 0

fixing tests

This commit is contained in:
Cadence Ember 2023-08-30 15:20:39 +12:00
parent 392151a75b
commit 6a04f3f798
2 changed files with 7 additions and 3 deletions

View file

@ -94,6 +94,7 @@ test("message2event: attachment with no content", async t => {
url: "mxc://cadence.moe/qXoZktDqNtEGuOCZEADAMvhM", url: "mxc://cadence.moe/qXoZktDqNtEGuOCZEADAMvhM",
body: "image.png", body: "image.png",
external_url: "https://cdn.discordapp.com/attachments/497161332244742154/1124628646431297546/image.png", external_url: "https://cdn.discordapp.com/attachments/497161332244742154/1124628646431297546/image.png",
filename: "image.png",
info: { info: {
mimetype: "image/png", mimetype: "image/png",
w: 466, w: 466,
@ -117,6 +118,7 @@ test("message2event: stickers", async t => {
url: "mxc://cadence.moe/ZDCNYnkPszxGKgObUIFmvjus", url: "mxc://cadence.moe/ZDCNYnkPszxGKgObUIFmvjus",
body: "image.png", body: "image.png",
external_url: "https://cdn.discordapp.com/attachments/122155380120748034/1106366167486038016/image.png", external_url: "https://cdn.discordapp.com/attachments/122155380120748034/1106366167486038016/image.png",
filename: "image.png",
info: { info: {
mimetype: "image/png", mimetype: "image/png",
w: 333, w: 333,
@ -155,6 +157,7 @@ test("message2event: skull webp attachment with content", async t => {
size: 74290 size: 74290
}, },
external_url: "https://cdn.discordapp.com/attachments/112760669178241024/1128084747910918195/skull.webp", external_url: "https://cdn.discordapp.com/attachments/112760669178241024/1128084747910918195/skull.webp",
filename: "skull.webp",
url: "mxc://cadence.moe/sDxWmDErBhYBxtDcJQgBETes" url: "mxc://cadence.moe/sDxWmDErBhYBxtDcJQgBETes"
}]) }])
}) })
@ -188,6 +191,7 @@ test("message2event: reply to skull webp attachment with content", async t => {
size: 85906 size: 85906
}, },
external_url: "https://cdn.discordapp.com/attachments/112760669178241024/1128084851023675515/RDT_20230704_0936184915846675925224905.jpg", external_url: "https://cdn.discordapp.com/attachments/112760669178241024/1128084851023675515/RDT_20230704_0936184915846675925224905.jpg",
filename: "RDT_20230704_0936184915846675925224905.jpg",
url: "mxc://cadence.moe/WlAbFSiNRIHPDEwKdyPeGywa" url: "mxc://cadence.moe/WlAbFSiNRIHPDEwKdyPeGywa"
}]) }])
}) })

View file

@ -31,7 +31,7 @@ const turndownService = new TurndownService({
turndownService.remove("mx-reply") turndownService.remove("mx-reply")
turndownService.addRule("strikethrough", { turndownService.addRule("strikethrough", {
filter: ["del", "s", "strike"], filter: ["del", "s"],
replacement: function (content) { replacement: function (content) {
return "~~" + content + "~~" return "~~" + content + "~~"
} }
@ -65,11 +65,11 @@ turndownService.addRule("spoiler", {
turndownService.addRule("inlineLink", { turndownService.addRule("inlineLink", {
filter: function (node, options) { filter: function (node, options) {
return ( return (
options.linkStyle === "inlined" && options.linkStyle === "inlined" &&
node.nodeName === "A" && node.nodeName === "A" &&
node.getAttribute("href") node.getAttribute("href")
) )
}, },
replacement: function (content, node) { replacement: function (content, node) {