From 38074374f4be6e8f6683925d463ff7bd5a15d77b Mon Sep 17 00:00:00 2001 From: Quentin Hibon Date: Sat, 10 Apr 2021 01:30:16 +0200 Subject: [PATCH] Add test --- ts/test-both/state/selectors/search_test.ts | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/ts/test-both/state/selectors/search_test.ts b/ts/test-both/state/selectors/search_test.ts index 2fcb62a0a0a1..ff471435bde6 100644 --- a/ts/test-both/state/selectors/search_test.ts +++ b/ts/test-both/state/selectors/search_test.ts @@ -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';