Add test
This commit is contained in:
parent
5623bb5906
commit
38074374f4
1 changed files with 60 additions and 0 deletions
|
@ -144,6 +144,66 @@ describe('both/state/selectors/search', () => {
|
||||||
|
|
||||||
assert.deepEqual(actual, expected);
|
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', () => {
|
it('returns outgoing message and caches appropriately', () => {
|
||||||
const searchId = 'search-id';
|
const searchId = 'search-id';
|
||||||
const fromId = 'from-id';
|
const fromId = 'from-id';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue