mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Introduce Service Id Types
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
committed by
Jamie Kyle
parent
414c0a58d3
commit
366b875fd2
@@ -9,9 +9,15 @@ import {
|
||||
getDeltaToRestartMention,
|
||||
} from '../../quill/util';
|
||||
import { BodyRange } from '../../types/BodyRange';
|
||||
import { generateAci } from '../../types/ServiceId';
|
||||
|
||||
const SERVICE_ID_1 = generateAci();
|
||||
const SERVICE_ID_2 = generateAci();
|
||||
const SERVICE_ID_3 = generateAci();
|
||||
const SERVICE_ID_4 = generateAci();
|
||||
|
||||
describe('getDeltaToRemoveStaleMentions', () => {
|
||||
const memberUuids = ['abcdef', 'ghijkl'];
|
||||
const memberUuids = [SERVICE_ID_1, SERVICE_ID_2];
|
||||
|
||||
describe('given text', () => {
|
||||
it('retains the text', () => {
|
||||
@@ -32,10 +38,10 @@ describe('getDeltaToRemoveStaleMentions', () => {
|
||||
const originalOps = [
|
||||
{
|
||||
insert: {
|
||||
mention: { uuid: '12345', title: 'Klaus' },
|
||||
mention: { uuid: SERVICE_ID_3, title: 'Klaus' },
|
||||
},
|
||||
},
|
||||
{ insert: { mention: { uuid: 'abcdef', title: 'Werner' } } },
|
||||
{ insert: { mention: { uuid: SERVICE_ID_1, title: 'Werner' } } },
|
||||
];
|
||||
|
||||
const { ops } = getDeltaToRemoveStaleMentions(originalOps, memberUuids);
|
||||
@@ -279,7 +285,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
{
|
||||
insert: {
|
||||
mention: {
|
||||
uuid: 'abcdef',
|
||||
uuid: SERVICE_ID_1,
|
||||
title: '@fred',
|
||||
},
|
||||
},
|
||||
@@ -290,7 +296,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
assert.deepEqual(bodyRanges, [
|
||||
{
|
||||
length: 1,
|
||||
mentionUuid: 'abcdef',
|
||||
mentionUuid: SERVICE_ID_1,
|
||||
replacementText: '@fred',
|
||||
start: 15,
|
||||
},
|
||||
@@ -304,7 +310,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
{
|
||||
insert: {
|
||||
mention: {
|
||||
uuid: 'abcdef',
|
||||
uuid: SERVICE_ID_1,
|
||||
title: '@fred',
|
||||
},
|
||||
},
|
||||
@@ -315,7 +321,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
assert.deepEqual(bodyRanges, [
|
||||
{
|
||||
length: 1,
|
||||
mentionUuid: 'abcdef',
|
||||
mentionUuid: SERVICE_ID_1,
|
||||
replacementText: '@fred',
|
||||
start: 0,
|
||||
},
|
||||
@@ -328,7 +334,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
{
|
||||
insert: {
|
||||
mention: {
|
||||
uuid: 'abcdef',
|
||||
uuid: SERVICE_ID_1,
|
||||
title: '@fred',
|
||||
},
|
||||
},
|
||||
@@ -340,7 +346,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
assert.deepEqual(bodyRanges, [
|
||||
{
|
||||
length: 1,
|
||||
mentionUuid: 'abcdef',
|
||||
mentionUuid: SERVICE_ID_1,
|
||||
replacementText: '@fred',
|
||||
start: 6,
|
||||
},
|
||||
@@ -360,7 +366,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
{
|
||||
insert: {
|
||||
mention: {
|
||||
uuid: 'a',
|
||||
uuid: SERVICE_ID_4,
|
||||
title: '@alice',
|
||||
},
|
||||
},
|
||||
@@ -419,7 +425,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
{
|
||||
start: 5,
|
||||
length: 1,
|
||||
mentionUuid: 'a',
|
||||
mentionUuid: SERVICE_ID_4,
|
||||
replacementText: '@alice',
|
||||
},
|
||||
{
|
||||
@@ -503,7 +509,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
{
|
||||
insert: {
|
||||
mention: {
|
||||
uuid: 'a',
|
||||
uuid: SERVICE_ID_4,
|
||||
title: '@alice',
|
||||
},
|
||||
},
|
||||
@@ -518,7 +524,7 @@ describe('getTextAndRangesFromOps', () => {
|
||||
{
|
||||
start: 0,
|
||||
length: 1,
|
||||
mentionUuid: 'a',
|
||||
mentionUuid: SERVICE_ID_4,
|
||||
replacementText: '@alice',
|
||||
},
|
||||
{
|
||||
@@ -543,7 +549,7 @@ describe('getDeltaToRestartMention', () => {
|
||||
{
|
||||
insert: {
|
||||
mention: {
|
||||
uuid: 'ghijkl',
|
||||
uuid: SERVICE_ID_2,
|
||||
title: '@sam',
|
||||
},
|
||||
},
|
||||
@@ -554,7 +560,7 @@ describe('getDeltaToRestartMention', () => {
|
||||
{
|
||||
insert: {
|
||||
mention: {
|
||||
uuid: 'abcdef',
|
||||
uuid: SERVICE_ID_1,
|
||||
title: '@fred',
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user