From acf829ed1cc914fa02c013821fccaf9c8e0b0efe Mon Sep 17 00:00:00 2001 From: Andre Christoga Pramaditya Date: Thu, 9 Jun 2022 07:53:28 +0700 Subject: [PATCH] feat(jest): 100% coverage for store/conversation/getters --- .../__snapshots__/getters.test.ts.snap | 14 ++++++++ store/conversation/getters.test.ts | 32 +++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/store/conversation/__snapshots__/getters.test.ts.snap b/store/conversation/__snapshots__/getters.test.ts.snap index e011f6f919..1f04a3b3a1 100644 --- a/store/conversation/__snapshots__/getters.test.ts.snap +++ b/store/conversation/__snapshots__/getters.test.ts.snap @@ -27,3 +27,17 @@ Array [ }, ] `; + +exports[`misc typingParticipants 1`] = ` +Array [ + Object { + "activity": "TYPING", + "address": "address2", + "name": "name2", + "peerId": "peerId2", + "profilePicture": "profilePicture2", + "state": "CONNECTED", + "updatedAt": 123, + }, +] +`; diff --git a/store/conversation/getters.test.ts b/store/conversation/getters.test.ts index 078b6ee06f..79ed292922 100644 --- a/store/conversation/getters.test.ts +++ b/store/conversation/getters.test.ts @@ -75,4 +75,36 @@ describe('misc', () => { expect(result).toMatchSnapshot() }) + + test('typingParticipants', () => { + const argument: ConversationParticipant[] = [ + { + peerId: 'peerId', + address: 'address', + name: 'name', + profilePicture: 'profilePicture', + state: ConversationConnection.DISCONNECTED, + activity: ConversationActivity.ACTIVE, // This element in this array will not be this included because it is not TYPING (type) + updatedAt: 123, + }, + { + peerId: 'peerId2', + address: 'address2', + name: 'name2', + profilePicture: 'profilePicture2', + state: ConversationConnection.CONNECTED, + activity: ConversationActivity.TYPING, + updatedAt: 123, + }, + ] + const localState = { ...InitialConversationState } + localState.participants = argument + + const result: ConversationParticipant[] = module.default.typingParticipants( + localState, + { otherParticipants: argument }, + ) + + expect(result).toMatchSnapshot() + }) })