Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jest): 100% coverage for store/webrtc/mutations #3762

Merged
merged 1 commit into from
Jun 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions store/webrtc/mutations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,79 @@ describe('Mutate WebRTC by setting', () => {
activeCall: '0x0',
})
})

it('should update createdAt', () => {
const localStateForUnitTest = { ...state }
inst.updateCreatedAt(localStateForUnitTest, 0x0)

expect(localStateForUnitTest).toMatchObject({
createdAt: 0x0,
})
})

it('should set streamMuted', () => {
const localStateForUnitTest = { ...state }
const argument = {
peerId: 'id',
audio: true,
video: true,
screen: true,
}
inst.setStreamMuted(localStateForUnitTest, argument)

expect(localStateForUnitTest.streamMuted).toMatchObject({
id: {
audio: true,
video: true,
screen: true,
},
})
})

it('should set muted', () => {
const localStateForUnitTest = { ...state }
const argument = {
peerId: 'id',
audio: true,
video: true,
screen: true,
}
inst.setStreamMuted(localStateForUnitTest, argument)
const secondArgument = {
peerId: 'id',
kind: 'audio',
muted: false,
}
inst.setMuted(localStateForUnitTest, secondArgument) // Audio muted is now false.

expect(localStateForUnitTest.streamMuted).toMatchObject({
id: { audio: false, video: true, screen: true },
})
})

it('should toggle mute', () => {
const localStateForUnitTest = { ...state }
const argument = {
peerId: 'id',
audio: true,
video: true,
screen: true,
}
inst.setStreamMuted(localStateForUnitTest, argument)
const secondArgument = {
peerId: 'id',
kind: 'audio',
muted: false,
}
inst.setMuted(localStateForUnitTest, secondArgument)
const thirdArgument = {
peerId: 'id',
kind: 'audio',
}
inst.toggleMute(localStateForUnitTest, thirdArgument) // Audio muted is now true again.

expect(localStateForUnitTest.streamMuted).toMatchObject({
id: { audio: true, video: true, screen: true },
})
})
})