|
|
|
@ -6,12 +6,14 @@ import {
|
|
|
|
|
setExpirationStartTimestamp,
|
|
|
|
|
} from '../../../../util/expiringMessages';
|
|
|
|
|
import { isValidUnixTimestamp } from '../../../../session/utils/Timestamps';
|
|
|
|
|
import { GetNetworkTime } from '../../../../session/apis/snode_api/getNetworkTime';
|
|
|
|
|
|
|
|
|
|
describe('Disappearing Messages', () => {
|
|
|
|
|
stubWindowLog();
|
|
|
|
|
const getLatestTimestampOffset = 200000;
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
// TODO Stubbing
|
|
|
|
|
Sinon.stub(GetNetworkTime, 'getLatestTimestampOffset').returns(getLatestTimestampOffset);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
@ -30,7 +32,6 @@ describe('Disappearing Messages', () => {
|
|
|
|
|
'it should be a valid unix timestamp'
|
|
|
|
|
).to.be.true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns a valid unix timestamp for deleteAfterSend', async () => {
|
|
|
|
|
const mode: DisappearingMessageConversationModeType = 'deleteAfterSend';
|
|
|
|
|
const expirationStartTimestamp = setExpirationStartTimestamp(mode);
|
|
|
|
@ -41,19 +42,49 @@ describe('Disappearing Messages', () => {
|
|
|
|
|
'it should be a valid unix timestamp'
|
|
|
|
|
).to.be.true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('returns undefined when disappearing messages is off', async () => {
|
|
|
|
|
const mode: DisappearingMessageConversationModeType = 'off';
|
|
|
|
|
const expirationStartTimestamp = setExpirationStartTimestamp(mode);
|
|
|
|
|
|
|
|
|
|
expect(expirationStartTimestamp, 'it should return undefined').to.be.undefined;
|
|
|
|
|
});
|
|
|
|
|
it('if we give it a timestamp it returns the older timestamp for deleteAfterRead', async () => {
|
|
|
|
|
const mode: DisappearingMessageConversationModeType = 'deleteAfterRead';
|
|
|
|
|
const timestamp = new Date().valueOf();
|
|
|
|
|
const expirationStartTimestamp = setExpirationStartTimestamp(mode, timestamp);
|
|
|
|
|
|
|
|
|
|
expect(expirationStartTimestamp, 'it should return a number').to.be.is.a('number');
|
|
|
|
|
expect(
|
|
|
|
|
isValidUnixTimestamp(expirationStartTimestamp!),
|
|
|
|
|
'it should be a valid unix timestamp'
|
|
|
|
|
).to.be.true;
|
|
|
|
|
expect(
|
|
|
|
|
expirationStartTimestamp,
|
|
|
|
|
'expirationStartTimestamp should be less than the input timestamp'
|
|
|
|
|
).to.be.lessThan(timestamp);
|
|
|
|
|
});
|
|
|
|
|
it('if we give it a timestamp it returns the older timestamp for deleteAfterSend', async () => {
|
|
|
|
|
const mode: DisappearingMessageConversationModeType = 'deleteAfterSend';
|
|
|
|
|
const timestamp = new Date().valueOf();
|
|
|
|
|
const expirationStartTimestamp = setExpirationStartTimestamp(mode, timestamp);
|
|
|
|
|
|
|
|
|
|
// TODO Test with timestamp argument
|
|
|
|
|
// Timestamp is bigger
|
|
|
|
|
// Timestamp is smaller
|
|
|
|
|
// Timestamp is the equal
|
|
|
|
|
// Timestamp is invalid
|
|
|
|
|
expect(expirationStartTimestamp, 'it should return a number').to.be.is.a('number');
|
|
|
|
|
expect(
|
|
|
|
|
isValidUnixTimestamp(expirationStartTimestamp!),
|
|
|
|
|
'it should be a valid unix timestamp'
|
|
|
|
|
).to.be.true;
|
|
|
|
|
expect(
|
|
|
|
|
expirationStartTimestamp,
|
|
|
|
|
'expirationStartTimestamp should be less than the input timestamp'
|
|
|
|
|
).to.be.lessThan(timestamp);
|
|
|
|
|
});
|
|
|
|
|
it('if we give it an invalid timestamp it returns undefined', async () => {
|
|
|
|
|
const mode: DisappearingMessageConversationModeType = 'deleteAfterSend';
|
|
|
|
|
const timestamp = -1;
|
|
|
|
|
const expirationStartTimestamp = setExpirationStartTimestamp(mode, timestamp);
|
|
|
|
|
|
|
|
|
|
expect(expirationStartTimestamp, 'it should return undefined').to.be.undefined;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('changeToDisappearingMessageType', async () => {
|
|
|
|
|