test: finished isExpirationTimerUpdate

added generateFakeExpirationTimerUpdate for testing
pull/2971/head
William Grant 2 years ago
parent bf5bcae4ac
commit bde674cbac

@ -3,6 +3,7 @@ import Sinon from 'sinon';
import chaiAsPromised from 'chai-as-promised';
import {
generateDisappearingVisibleMessage,
generateFakeExpirationTimerUpdate,
generateVisibleMessage,
stubWindowLog,
} from '../../../test-utils/utils';
@ -576,8 +577,24 @@ describe('Disappearing Messages', () => {
describe('message.ts', () => {
describe('isExpirationTimerUpdate', () => {
it('TODO', async () => {
expect('TODO').to.be.eq('TODO');
it('should return true if valid', async () => {
const expirationTimerUpdateMessage = generateFakeExpirationTimerUpdate({
expirationType: 'deleteAfterSend',
expireTimer: 300,
lastDisappearingMessageChangeTimestamp: GetNetworkTime.getNowWithNetworkOffset(),
source: '050123456789abcdef050123456789abcdef0123456789abcdef050123456789ab',
});
expect(expirationTimerUpdateMessage.get('flags'), 'flags should be 2').to.equal(2);
expect(
expirationTimerUpdateMessage.getExpirationTimerUpdate(),
'expirationTimerUpdate should not be empty'
).to.not.be.empty;
expect(
expirationTimerUpdateMessage.getExpirationTimerUpdate(),
'expirationTimerUpdate should not be empty'
).to.not.be.empty;
expect(expirationTimerUpdateMessage.isExpirationTimerUpdate(), 'should be true').to.be.true;
});
});
});

@ -159,3 +159,31 @@ export function generateDisappearingVisibleMessage({
preview: undefined,
});
}
export function generateFakeExpirationTimerUpdate({
expirationType,
expireTimer,
lastDisappearingMessageChangeTimestamp,
source = '',
}: {
expirationType: DisappearingMessageType;
expireTimer: number;
lastDisappearingMessageChangeTimestamp: number;
source?: string;
}): MessageModel {
const convoId = TestUtils.generateFakePubKeyStr();
return new MessageModel({
conversationId: convoId,
source: convoId,
type: 'incoming',
expirationType,
expireTimer,
expirationTimerUpdate: {
expirationType,
expireTimer,
lastDisappearingMessageChangeTimestamp,
source,
},
flags: 2,
});
}

Loading…
Cancel
Save