diff --git a/src/__tests__/lib/exampleData.js b/src/__tests__/lib/exampleData.js index 78d626d9665..aa50fd590a1 100644 --- a/src/__tests__/lib/exampleData.js +++ b/src/__tests__/lib/exampleData.js @@ -228,6 +228,9 @@ export const displayRecipientFromUser = (user: User): PmRecipientUser => { }); }; +export const displayRecipientFromUsers = (users: User[]): PmRecipientUser[] => + users.map(user => displayRecipientFromUser(user)); + /** Boring properties common to all example Message objects. */ const messagePropertiesBase = deepFreeze({ isOutbox: false, diff --git a/src/pm-conversations/__tests__/pmConversationsSelectors-test.js b/src/pm-conversations/__tests__/pmConversationsSelectors-test.js index 7edd2b72b90..86e1c94d299 100644 --- a/src/pm-conversations/__tests__/pmConversationsSelectors-test.js +++ b/src/pm-conversations/__tests__/pmConversationsSelectors-test.js @@ -31,26 +31,17 @@ describe('getRecentConversations', () => { test('returns unique list of recipients, includes conversations with self', () => { const meAndJohnPm1 = eg.pmMessage({ id: 1, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userJohn), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userJohn]), }); const meAndMarkPm = eg.pmMessage({ id: 2, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userMark), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userMark]), }); const meAndJohnPm2 = eg.pmMessage({ id: 3, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userJohn), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userJohn]), }); const meOnlyPm = eg.pmMessage({ @@ -60,11 +51,7 @@ describe('getRecentConversations', () => { const meJohnAndMarkPm = eg.pmMessage({ id: 0, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userMark), - eg.displayRecipientFromUser(userJohn), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userMark, userJohn]), }); const state = eg.reduxState({ @@ -155,43 +142,27 @@ describe('getRecentConversations', () => { const meAndMarkPm1 = eg.pmMessage({ id: 1, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userMark), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userMark]), }); const meAndJohnPm1 = eg.pmMessage({ id: 2, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userJohn), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userJohn]), }); const meAndMarkPm2 = eg.pmMessage({ id: 3, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userMark), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userMark]), }); const meAndJohnPm2 = eg.pmMessage({ id: 4, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userJohn), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userJohn]), }); const meJohnAndMarkPm = eg.pmMessage({ id: 5, - display_recipient: [ - eg.displayRecipientFromUser(eg.selfUser), - eg.displayRecipientFromUser(userJohn), - eg.displayRecipientFromUser(userMark), - ], + display_recipient: eg.displayRecipientFromUsers([eg.selfUser, userJohn, userMark]), }); const meOnlyPm = eg.pmMessage({