mirror of
https://gitdab.com/cadence/out-of-your-element.git
synced 2025-09-10 20:32:50 +02:00
Add tests for reactions interaction
This commit is contained in:
parent
61803c3838
commit
33915a595d
6 changed files with 121 additions and 14 deletions
87
src/discord/interactions/reactions.test.js
Normal file
87
src/discord/interactions/reactions.test.js
Normal file
|
@ -0,0 +1,87 @@
|
|||
const {test} = require("supertape")
|
||||
const data = require("../../../test/data")
|
||||
const DiscordTypes = require("discord-api-types/v10")
|
||||
const {db, discord} = require("../../passthrough")
|
||||
const {MatrixServerError} = require("../../matrix/mreq")
|
||||
const {_interact} = require("./reactions")
|
||||
|
||||
test("reactions: checks if message is bridged", async t => {
|
||||
const msg = await _interact({
|
||||
data: {
|
||||
target_id: "0"
|
||||
}
|
||||
}, {})
|
||||
t.equal(msg.data.content, "This message hasn't been bridged to Matrix.")
|
||||
})
|
||||
|
||||
test("reactions: different response if nobody reacted", async t => {
|
||||
const msg = await _interact({
|
||||
data: {
|
||||
target_id: "1126786462646550579"
|
||||
}
|
||||
}, {
|
||||
api: {
|
||||
async getFullRelations(roomID, eventID) {
|
||||
t.equal(roomID, "!kLRqKKUQXcibIMtOpl:cadence.moe")
|
||||
t.equal(eventID, "$X16nfVks1wsrhq4E9SSLiqrf2N8KD0erD0scZG7U5xg")
|
||||
return []
|
||||
}
|
||||
}
|
||||
})
|
||||
t.equal(msg.data.content, "Nobody from Matrix reacted to this message.")
|
||||
})
|
||||
|
||||
test("reactions: shows reactions if there are some, ignoring discord users", async t => {
|
||||
let called = 1
|
||||
const msg = await _interact({
|
||||
data: {
|
||||
target_id: "1126786462646550579"
|
||||
}
|
||||
}, {
|
||||
api: {
|
||||
async getFullRelations(roomID, eventID) {
|
||||
t.equal(roomID, "!kLRqKKUQXcibIMtOpl:cadence.moe")
|
||||
t.equal(eventID, "$X16nfVks1wsrhq4E9SSLiqrf2N8KD0erD0scZG7U5xg")
|
||||
return [{
|
||||
sender: "@cadence:cadence.moe",
|
||||
content: {
|
||||
"m.relates_to": {
|
||||
key: "🐈",
|
||||
rel_type: "m.annotation"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
sender: "@rnl:cadence.moe",
|
||||
content: {
|
||||
"m.relates_to": {
|
||||
key: "🐈",
|
||||
rel_type: "m.annotation"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
sender: "@cadence:cadence.moe",
|
||||
content: {
|
||||
"m.relates_to": {
|
||||
key: "🐈⬛",
|
||||
rel_type: "m.annotation"
|
||||
}
|
||||
}
|
||||
}, {
|
||||
sender: "@_ooye_rnl:cadence.moe",
|
||||
content: {
|
||||
"m.relates_to": {
|
||||
key: "🐈",
|
||||
rel_type: "m.annotation"
|
||||
}
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
})
|
||||
t.equal(
|
||||
msg.data.content,
|
||||
"🐈 ⮞ cadence [they] ⬩ @rnl:cadence.moe"
|
||||
+ "\n🐈⬛ ⮞ cadence [they]"
|
||||
)
|
||||
t.equal(called, 1)
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue