You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { expect } from 'chai';
|
|
import { beforeEach } from 'mocha';
|
|
|
|
import { SignalService } from '../../../../protobuf';
|
|
import { toNumber } from 'lodash';
|
|
import { Constants } from '../../../../session';
|
|
import { ReadReceiptMessage } from '../../../../session/messages/outgoing/controlMessage/receipt/ReadReceiptMessage';
|
|
|
|
describe('ReceiptMessage', () => {
|
|
let readMessage: ReadReceiptMessage;
|
|
let timestamps: Array<number>;
|
|
|
|
beforeEach(() => {
|
|
timestamps = [987654321, 123456789];
|
|
const timestamp = Date.now();
|
|
readMessage = new ReadReceiptMessage({ timestamp, timestamps });
|
|
});
|
|
|
|
it('content of a read receipt is correct', () => {
|
|
const plainText = readMessage.plainTextBuffer();
|
|
const decoded = SignalService.Content.decode(plainText);
|
|
|
|
expect(decoded.receiptMessage).to.have.property('type', 1);
|
|
const decodedTimestamps = (decoded.receiptMessage?.timestamp ?? []).map(toNumber);
|
|
expect(decodedTimestamps).to.deep.equal(timestamps);
|
|
});
|
|
|
|
it('correct ttl', () => {
|
|
expect(readMessage.ttl()).to.equal(Constants.TTL_DEFAULT.TTL_MAX);
|
|
});
|
|
|
|
it('has an identifier', () => {
|
|
expect(readMessage.identifier).to.not.equal(null, 'identifier cannot be null');
|
|
expect(readMessage.identifier).to.not.equal(undefined, 'identifier cannot be undefined');
|
|
});
|
|
});
|