This commit is contained in:
Quentin Hibon 2021-04-10 01:30:16 +02:00
parent 5623bb5906
commit 38074374f4

View file

@ -144,6 +144,66 @@ describe('both/state/selectors/search', () => {
assert.deepEqual(actual, expected);
});
it('returns incoming message and has the correct "to" when sent to me', () => {
const searchId = 'search-id';
const fromId = 'from-id';
const toId = fromId;
const myId = 'my-id';
const from = getDefaultConversation(fromId);
const meAsRecipient = getDefaultConversation(myId);
const state = {
...getEmptyRootState(),
conversations: {
...getEmptyConversationState(),
conversationLookup: {
[fromId]: from,
[myId]: meAsRecipient,
},
},
ourConversationId: myId,
search: {
...getEmptySearchState(),
messageLookup: {
[searchId]: {
...getDefaultMessage(searchId),
type: 'incoming' as const,
sourceUuid: fromId,
conversationId: toId,
snippet: 'snippet',
body: 'snippet',
bodyRanges: [],
},
},
},
user: {
...getEmptyUserState(),
ourConversationId: myId,
},
};
const selector = getMessageSearchResultSelector(state);
const actual = selector(searchId);
const expected = {
from,
to: meAsRecipient,
id: searchId,
conversationId: toId,
sentAt: undefined,
snippet: 'snippet',
body: 'snippet',
bodyRanges: [],
isSelected: false,
isSearchingInConversation: false,
};
assert.deepEqual(actual, expected);
});
it('returns outgoing message and caches appropriately', () => {
const searchId = 'search-id';
const fromId = 'from-id';