Files
Desktop/ts/test-node/processSent_test.node.ts
2026-03-30 11:54:59 -07:00

59 lines
1.6 KiB
TypeScript

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import lodash from 'lodash';
import { generateAci } from '../types/ServiceId.std.ts';
import { signalservice as Proto } from '../protobuf/compiled.std.js';
import { processSent } from '../textsecure/processSyncMessage.node.ts';
const { omit } = lodash;
describe('processSent', () => {
const destinationServiceId = generateAci();
it('should normalize UUIDs in sent', () => {
const input = Proto.SyncMessage.Sent.decode(
Proto.SyncMessage.Sent.encode({
destinationServiceId: destinationServiceId.toUpperCase(),
destinationServiceIdBinary: null,
unidentifiedStatus: [
{
destinationServiceId: destinationServiceId.toUpperCase(),
unidentified: null,
destinationServiceIdBinary: null,
destinationPniIdentityKey: null,
},
],
destinationE164: null,
timestamp: null,
message: null,
expirationStartTimestamp: null,
isRecipientUpdate: null,
storyMessage: null,
storyMessageRecipients: null,
editMessage: null,
})
);
const out = processSent(input);
assert.deepStrictEqual(out, {
...omit(input, 'destinationServiceIdBinary', '$unknown'),
destinationServiceId,
unidentifiedStatus: [
{
$unknown: [],
destinationPniIdentityKey: undefined,
destinationServiceId,
unidentified: false,
},
],
storyMessageRecipients: [],
} as unknown);
});
});