2023-07-02 13:06:05 +00:00
|
|
|
// @ts-check
|
|
|
|
|
|
|
|
const {test} = require("supertape")
|
|
|
|
const {eventToMessage} = require("./event-to-message")
|
|
|
|
const data = require("../../test/data")
|
|
|
|
|
|
|
|
test("event2message: janky test", t => {
|
|
|
|
t.deepEqual(
|
|
|
|
eventToMessage({
|
|
|
|
content: {
|
|
|
|
body: "test",
|
|
|
|
msgtype: "m.text"
|
|
|
|
},
|
|
|
|
event_id: "$g07oYSZFWBkxohNEfywldwgcWj1hbhDzQ1sBAKvqOOU",
|
|
|
|
origin_server_ts: 1688301929913,
|
|
|
|
room_id: "!kLRqKKUQXcibIMtOpl:cadence.moe",
|
|
|
|
sender: "@cadence:cadence.moe",
|
|
|
|
type: "m.room.message",
|
|
|
|
unsigned: {
|
|
|
|
age: 405299
|
2023-07-03 12:39:42 +00:00
|
|
|
}
|
2023-07-02 13:06:05 +00:00
|
|
|
}),
|
|
|
|
[{
|
2023-08-19 10:54:23 +00:00
|
|
|
username: "cadence",
|
2023-07-02 13:06:05 +00:00
|
|
|
content: "test",
|
|
|
|
avatar_url: undefined
|
|
|
|
}]
|
|
|
|
)
|
|
|
|
})
|
2023-08-23 12:35:35 +00:00
|
|
|
|
|
|
|
test("event2message: long messages are split", t => {
|
|
|
|
t.deepEqual(
|
|
|
|
eventToMessage({
|
|
|
|
content: {
|
|
|
|
body: ("a".repeat(130) + " ").repeat(19),
|
|
|
|
msgtype: "m.text"
|
|
|
|
},
|
|
|
|
event_id: "$g07oYSZFWBkxohNEfywldwgcWj1hbhDzQ1sBAKvqOOU",
|
|
|
|
origin_server_ts: 1688301929913,
|
|
|
|
room_id: "!kLRqKKUQXcibIMtOpl:cadence.moe",
|
|
|
|
sender: "@cadence:cadence.moe",
|
|
|
|
type: "m.room.message",
|
|
|
|
unsigned: {
|
|
|
|
age: 405299
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
[{
|
|
|
|
username: "cadence",
|
|
|
|
content: (("a".repeat(130) + " ").repeat(15)).slice(0, -1),
|
|
|
|
avatar_url: undefined
|
|
|
|
}, {
|
|
|
|
username: "cadence",
|
|
|
|
content: (("a".repeat(130) + " ").repeat(4)).slice(0, -1),
|
|
|
|
avatar_url: undefined
|
|
|
|
}]
|
|
|
|
)
|
|
|
|
})
|