Add "new conversation" composer for direct messages

This commit is contained in:
Evan Hahn 2021-02-23 14:34:28 -06:00 committed by Josh Perez
parent 84dc166b63
commit 06fb4fd0bc
61 changed files with 5960 additions and 3887 deletions

View file

@ -0,0 +1,19 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { deconstructLookup } from '../../util/deconstructLookup';
describe('deconstructLookup', () => {
it('looks up an array of properties in a lookup', () => {
const lookup = {
high: 5,
seven: 89,
big: 999,
};
const keys = ['seven', 'high'];
assert.deepEqual(deconstructLookup(lookup, keys), [89, 5]);
});
});

View file

@ -0,0 +1,46 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { isConversationUnread } from '../../util/isConversationUnread';
describe('isConversationUnread', () => {
it('returns false if both markedUnread and unreadCount are undefined', () => {
assert.isFalse(isConversationUnread({}));
assert.isFalse(
isConversationUnread({
markedUnread: undefined,
unreadCount: undefined,
})
);
});
it('returns false if markedUnread is false', () => {
assert.isFalse(isConversationUnread({ markedUnread: false }));
});
it('returns false if unreadCount is 0', () => {
assert.isFalse(isConversationUnread({ unreadCount: 0 }));
});
it('returns true if markedUnread is true, regardless of unreadCount', () => {
assert.isTrue(isConversationUnread({ markedUnread: true }));
assert.isTrue(isConversationUnread({ markedUnread: true, unreadCount: 0 }));
assert.isTrue(
isConversationUnread({ markedUnread: true, unreadCount: 100 })
);
});
it('returns true if unreadCount is positive, regardless of markedUnread', () => {
assert.isTrue(isConversationUnread({ unreadCount: 1 }));
assert.isTrue(isConversationUnread({ unreadCount: 99 }));
assert.isTrue(
isConversationUnread({ markedUnread: false, unreadCount: 2 })
);
});
it('returns true if both markedUnread is true and unreadCount is positive', () => {
assert.isTrue(isConversationUnread({ markedUnread: true, unreadCount: 1 }));
});
});

View file

@ -0,0 +1,50 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { assert } from 'chai';
import { isConversationUnregistered } from '../../util/isConversationUnregistered';
describe('isConversationUnregistered', () => {
it('returns false if passed an undefined discoveredUnregisteredAt', () => {
assert.isFalse(isConversationUnregistered({}));
assert.isFalse(
isConversationUnregistered({ discoveredUnregisteredAt: undefined })
);
});
it('returns false if passed a time fewer than 6 hours ago', () => {
assert.isFalse(
isConversationUnregistered({ discoveredUnregisteredAt: Date.now() })
);
const fiveHours = 1000 * 60 * 60 * 5;
assert.isFalse(
isConversationUnregistered({
discoveredUnregisteredAt: Date.now() - fiveHours,
})
);
});
it('returns false if passed a time in the future', () => {
assert.isFalse(
isConversationUnregistered({ discoveredUnregisteredAt: Date.now() + 123 })
);
});
it('returns true if passed a time more than 6 hours ago', () => {
const oneMinute = 1000 * 60;
const sixHours = 1000 * 60 * 60 * 6;
assert.isTrue(
isConversationUnregistered({
discoveredUnregisteredAt: Date.now() - sixHours - oneMinute,
})
);
assert.isTrue(
isConversationUnregistered({
discoveredUnregisteredAt: new Date(1999, 3, 20).getTime(),
})
);
});
});