Support for receiving formatted messages

Co-authored-by: Alvaro Carrasco <alvaro@signal.org>
This commit is contained in:
Scott Nonnenberg
2023-04-10 09:31:45 -07:00
committed by GitHub
parent d34d187f1e
commit d9d820e72a
72 changed files with 3421 additions and 858 deletions

View File

@@ -1,50 +0,0 @@
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { getTextWithMentions } from '../../util/getTextWithMentions';
describe('getTextWithMentions', () => {
describe('given mention replacements', () => {
it('replaces them', () => {
const bodyRanges = [
{
length: 1,
mentionUuid: 'abcdef',
replacementText: 'fred',
conversationID: 'x',
start: 4,
},
];
const text = "Hey \uFFFC, I'm here";
assert.strictEqual(
getTextWithMentions(bodyRanges, text),
"Hey @fred, I'm here"
);
});
it('sorts them to go from back to front', () => {
const bodyRanges = [
{
length: 1,
mentionUuid: 'blarg',
replacementText: 'jerry',
conversationID: 'x',
start: 0,
},
{
length: 1,
mentionUuid: 'abcdef',
replacementText: 'fred',
conversationID: 'x',
start: 7,
},
];
const text = "\uFFFC says \uFFFC, I'm here";
assert.strictEqual(
getTextWithMentions(bodyRanges, text),
"@jerry says @fred, I'm here"
);
});
});
});