From 4c1aeb342a1904f39cf45a05ba9bc810a9d887f1 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Fri, 6 Aug 2021 10:35:45 -0700 Subject: [PATCH] Add two new tests for replies --- .../session/room/timeline/deserialize.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/domain/session/room/timeline/deserialize.js b/src/domain/session/room/timeline/deserialize.js index e937bc7b..ce690732 100644 --- a/src/domain/session/room/timeline/deserialize.js +++ b/src/domain/session/room/timeline/deserialize.js @@ -397,8 +397,8 @@ export function tests() { parseHTML: (html) => new HTMLParseResult(parse(html)) }; - function test(assert, input, output) { - assert.deepEqual(parseHTMLBody(platform, null, true, input), new MessageBody(input, output)); + function test(assert, input, output, replies=true) { + assert.deepEqual(parseHTMLBody(platform, null, replies, input), new MessageBody(input, output)); } return { @@ -495,6 +495,24 @@ export function tests() { new CodeBlock(null, code) ]; test(assert, input, output); + }, + "Replies are inserted when allowed": assert => { + const input = 'Hello, World!'; + const output = [ + new TextPart('Hello, '), + new FormatPart("em", [new TextPart('World')]), + new TextPart('!'), + ]; + test(assert, input, output); + }, + "Replies are stripped when not allowed": assert => { + const input = 'Hello, World!'; + const output = [ + new TextPart('Hello, '), + new FormatPart("em", []), + new TextPart('!'), + ]; + test(assert, input, output, false); } /* Doesnt work: HTML library doesn't handle
 properly.
         "Text with code block": assert => {