From 4c0aa57ba77da5a5de33b00a0669031a2b850980 Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Thu, 24 Aug 2023 00:35:35 +1200 Subject: [PATCH] add test case for m->d too-long message --- m2d/converters/event-to-message.test.js | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/m2d/converters/event-to-message.test.js b/m2d/converters/event-to-message.test.js index f0c4664..a45c23b 100644 --- a/m2d/converters/event-to-message.test.js +++ b/m2d/converters/event-to-message.test.js @@ -27,3 +27,31 @@ test("event2message: janky test", t => { }] ) }) + +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 + }] + ) +})