Skip to content

Commit

Permalink
migrateMessages tests [nfc]: Make type alias for something we write t…
Browse files Browse the repository at this point in the history
…wice.

This type is about to grow another exception besides 'reactions':
'avatar_url'.
  • Loading branch information
chrisbobbe authored and gnprice committed Aug 13, 2020
1 parent eb2fd33 commit 99f959f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/api/messages/__tests__/migrateMessages-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ describe('migrateMessages', () => {
},
};

type CommonFields = $Diff<Message, { reactions: mixed }>;

const serverMessage: ServerMessage = {
// The `omit` shouldn't be necessary with Flow v0.111: "Spreads
// now overwrite properties instead of inferring unions"
// (https://medium.com/flow-type/spreads-common-errors-fixes-9701012e9d58).
...(omit(eg.streamMessage(), 'reactions'): $Diff<Message, { reactions: mixed }>),
...(omit(eg.streamMessage(), 'reactions'): CommonFields),
reactions: [serverReaction],
};

Expand All @@ -33,7 +35,7 @@ describe('migrateMessages', () => {
const expectedOutput: Message[] = [
{
// The `omit` shouldn't be necessary with Flow v0.111.
...(omit(serverMessage, 'reactions'): $Diff<ServerMessage, { reactions: mixed }>),
...(omit(serverMessage, 'reactions'): CommonFields),
reactions: [
{
user_id: reactingUser.user_id,
Expand Down

0 comments on commit 99f959f

Please sign in to comment.