Improve experience for contacts without signal accounts

This commit is contained in:
Fedor Indutny 2021-05-13 13:57:27 -07:00 committed by Scott Nonnenberg
parent fe505a7f2f
commit 7fa730531a
11 changed files with 266 additions and 3 deletions

View file

@ -0,0 +1,47 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { isConversationSMSOnly } from '../../util/isConversationSMSOnly';
describe('isConversationSMSOnly', () => {
it('returns false if passed an undefined discoveredUnregisteredAt', () => {
assert.isFalse(isConversationSMSOnly({}));
assert.isFalse(
isConversationSMSOnly({ discoveredUnregisteredAt: undefined })
);
});
['direct', 'private'].forEach(type => {
it(`returns true if passed a time fewer than 6 hours ago and is ${type}`, () => {
assert.isTrue(
isConversationSMSOnly({
type,
e164: 'e164',
uuid: 'uuid',
discoveredUnregisteredAt: Date.now(),
})
);
const fiveHours = 1000 * 60 * 60 * 5;
assert.isTrue(
isConversationSMSOnly({
type,
e164: 'e164',
uuid: 'uuid',
discoveredUnregisteredAt: Date.now() - fiveHours,
})
);
});
it(`returns true conversation is ${type} and has no uuid`, () => {
assert.isTrue(isConversationSMSOnly({ type, e164: 'e164' }));
assert.isFalse(isConversationSMSOnly({ type }));
});
});
it('returns false for groups', () => {
assert.isFalse(isConversationSMSOnly({ type: 'group' }));
});
});