From 286418976b6792f0333084d24a3fd336f9945f55 Mon Sep 17 00:00:00 2001 From: William Grant Date: Thu, 12 Oct 2023 11:06:23 +1100 Subject: [PATCH] test: updated ChatMessage with disappearing tests for both modes --- .../session/unit/messages/ChatMessage_test.ts | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/ts/test/session/unit/messages/ChatMessage_test.ts b/ts/test/session/unit/messages/ChatMessage_test.ts index 964e60d68..d7c1b5f53 100644 --- a/ts/test/session/unit/messages/ChatMessage_test.ts +++ b/ts/test/session/unit/messages/ChatMessage_test.ts @@ -1,5 +1,5 @@ -import { TextEncoder } from 'util'; import { expect } from 'chai'; +import { TextEncoder } from 'util'; import { toNumber } from 'lodash'; import { SignalService } from '../../../../protobuf'; @@ -32,15 +32,40 @@ describe('VisibleMessage', () => { expect(decoded.dataMessage).to.have.deep.property('body', 'body'); }); - // TODO move into Disappearing Messages test - it('can create message with a expire timer', () => { + it('can create a disappear after read message', () => { + const message = new VisibleMessage({ + timestamp: Date.now(), + expirationType: 'deleteAfterRead', + expireTimer: 300, + }); + const plainText = message.plainTextBuffer(); + const decoded = SignalService.Content.decode(plainText); + expect(decoded, 'should have an expirationType of deleteAfterRead').to.have.deep.property( + 'expirationType', + SignalService.Content.ExpirationType.DELETE_AFTER_READ + ); + expect(decoded, 'should have an expirationTimer of 5 minutes').to.have.deep.property( + 'expirationTimer', + 300 + ); + }); + + it('can create a disappear after send message', () => { const message = new VisibleMessage({ timestamp: Date.now(), - expireTimer: 3600, + expirationType: 'deleteAfterSend', + expireTimer: 60, }); const plainText = message.plainTextBuffer(); const decoded = SignalService.Content.decode(plainText); - expect(decoded.dataMessage).to.have.deep.property('expireTimer', 3600); + expect(decoded, 'should have an expirationType of deleteAfterSend').to.have.deep.property( + 'expirationType', + SignalService.Content.ExpirationType.DELETE_AFTER_SEND + ); + expect(decoded, 'should have an expirationTimer of 1 minute').to.have.deep.property( + 'expirationTimer', + 60 + ); }); it('can create message with a full loki profile', () => {