Fix SMS-only check for unregistered convo
This commit is contained in:
parent
373ffe4663
commit
6e19383a7d
|
@ -6,14 +6,32 @@ import { assert } from 'chai';
|
||||||
import { isConversationSMSOnly } from '../../util/isConversationSMSOnly';
|
import { isConversationSMSOnly } from '../../util/isConversationSMSOnly';
|
||||||
|
|
||||||
describe('isConversationSMSOnly', () => {
|
describe('isConversationSMSOnly', () => {
|
||||||
it('returns false if passed an undefined discoveredUnregisteredAt', () => {
|
it('returns false if passed an undefined type', () => {
|
||||||
assert.isFalse(isConversationSMSOnly({}));
|
|
||||||
assert.isFalse(
|
assert.isFalse(
|
||||||
isConversationSMSOnly({ discoveredUnregisteredAt: undefined })
|
isConversationSMSOnly({
|
||||||
|
type: undefined,
|
||||||
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
['direct', 'private'].forEach(type => {
|
['direct', 'private'].forEach(type => {
|
||||||
|
it('returns false if passed an undefined discoveredUnregisteredAt', () => {
|
||||||
|
assert.isFalse(
|
||||||
|
isConversationSMSOnly({ type, discoveredUnregisteredAt: undefined })
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns true if passed a very old discoveredUnregisteredAt', () => {
|
||||||
|
assert.isTrue(
|
||||||
|
isConversationSMSOnly({
|
||||||
|
type,
|
||||||
|
e164: 'e164',
|
||||||
|
uuid: 'uuid',
|
||||||
|
discoveredUnregisteredAt: 1,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it(`returns true if passed a time fewer than 6 hours ago and is ${type}`, () => {
|
it(`returns true if passed a time fewer than 6 hours ago and is ${type}`, () => {
|
||||||
assert.isTrue(
|
assert.isTrue(
|
||||||
isConversationSMSOnly({
|
isConversationSMSOnly({
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
// Copyright 2021 Signal Messenger, LLC
|
// Copyright 2021 Signal Messenger, LLC
|
||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import { isConversationUnregistered } from './isConversationUnregistered';
|
|
||||||
|
|
||||||
export type MinimalConversationType = Readonly<{
|
export type MinimalConversationType = Readonly<{
|
||||||
type?: string;
|
type?: string;
|
||||||
e164?: string;
|
e164?: string;
|
||||||
|
@ -23,5 +21,5 @@ export function isConversationSMSOnly(
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return isConversationUnregistered(conversation);
|
return conversation.discoveredUnregisteredAt !== undefined;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue