From 0f5f1b63f34e33d7c156db26970d6f6f08e8ef50 Mon Sep 17 00:00:00 2001 From: Andre Christoga Pramaditya Date: Tue, 21 Jun 2022 20:11:18 +0700 Subject: [PATCH] feat(jest): 100% branch coverage for store/webrtc/mutations --- store/webrtc/mutations.test.ts | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/store/webrtc/mutations.test.ts b/store/webrtc/mutations.test.ts index 3c19697e16..73f672b1ce 100644 --- a/store/webrtc/mutations.test.ts +++ b/store/webrtc/mutations.test.ts @@ -91,6 +91,15 @@ describe('Mutate WebRTC by setting', () => { }) }) + it('should initialize with default value for parameters', () => { + const localStateForUnitTest = { ...state } + inst.setInitialized(localStateForUnitTest) + + expect(localStateForUnitTest).toMatchObject({ + webrtc: { initialized: true }, + }) + }) + it('should set incoming call', () => { const localStateForUnitTest = { ...state } inst.setIncomingCall(localStateForUnitTest, '0x0') @@ -137,6 +146,49 @@ describe('Mutate WebRTC by setting', () => { }) }) + it('should set streamMuted without peerId', () => { + const localStateForUnitTest = { ...state } + const argument = { + peerId: null, + audio: true, + video: true, + screen: true, + } + inst.setStreamMuted(localStateForUnitTest, argument) + + expect(localStateForUnitTest).not.toMatchObject({ + streamMuted: { + id: { + audio: true, + video: true, + screen: true, + }, + }, + }) + }) + + it('should set streamMuted without peerId and with default arguments', () => { + const localStateForUnitTest = { ...state } + const argument = { + peerId: null, + // Commented out because we want to test if default values will come in. + // audio: true, + // video: true, + // screen: true, + } + inst.setStreamMuted(localStateForUnitTest, argument) + + expect(localStateForUnitTest).not.toMatchObject({ + streamMuted: { + id: { + audio: true, + video: true, + screen: true, + }, + }, + }) + }) + it('should set muted', () => { const localStateForUnitTest = { ...state } const argument = {