Skip to content

Commit

Permalink
example data: Add displayRecipientFromUsers.
Browse files Browse the repository at this point in the history
And show how to use it. [1]

[1] #4187 (comment)
  • Loading branch information
chrisbobbe committed Jul 21, 2020
1 parent 84c5b8f commit b264ece
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 38 deletions.
3 changes: 3 additions & 0 deletions src/__tests__/lib/exampleData.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
47 changes: 9 additions & 38 deletions src/pm-conversations/__tests__/pmConversationsSelectors-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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({
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit b264ece

Please sign in to comment.