Don't mutate state in TimelineItem

This commit is contained in:
Fedor Indutny 2021-08-19 13:14:41 -07:00 committed by GitHub
parent 1cc7c5dc2d
commit 80c1ad6ee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 127 additions and 61 deletions

View file

@ -1737,6 +1737,7 @@ describe('both/state/selectors/conversations', () => {
it('returns the right color order sorted by UUID ASC', () => {
const group = makeConversation('group');
group.type = 'group';
group.sortedGroupMembers = [
makeConversationWithUuid('zyx'),
makeConversationWithUuid('vut'),
@ -1766,5 +1767,28 @@ describe('both/state/selectors/conversations', () => {
assert.equal(contactNameColorSelector('group', 'vut'), '330');
assert.equal(contactNameColorSelector('group', 'zyx'), '230');
});
it('returns the right colors for direct conversation', () => {
const direct = makeConversation('theirId');
const emptyState = getEmptyRootState();
const state = {
...emptyState,
user: {
...emptyState.user,
ourConversationId: 'us',
},
conversations: {
...getEmptyState(),
conversationLookup: {
direct,
},
},
};
const contactNameColorSelector = getContactNameColorSelector(state);
assert.equal(contactNameColorSelector('direct', 'theirId'), '200');
assert.equal(contactNameColorSelector('direct', 'us'), '200');
});
});
});