Skip to content

Commit

Permalink
fix(participantStore): update the whole participant object
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jan 25, 2024
1 parent 931617e commit e8dbc00
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/store/participantsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ const mutations = {

updateParticipant(state, { token, attendeeId, updatedData }) {
if (state.attendees[token] && state.attendees[token][attendeeId]) {
state.attendees[token][attendeeId] = Object.assign(state.attendees[token][attendeeId], updatedData)
state.attendees[token][attendeeId] = Object.assign({}, state.attendees[token][attendeeId], updatedData)
} else {
console.error('Error while updating the participant')
}
Expand Down
7 changes: 5 additions & 2 deletions src/store/participantsStore.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ describe('participantsStore', () => {
})

describe('joining conversation', () => {
let getTokenMock
let getParticipantIdentifierMock
let participantData
let joinedConversationEventMock
Expand All @@ -625,6 +626,7 @@ describe('participantsStore', () => {
joinedConversationEventMock = jest.fn()
EventBus.$once('joined-conversation', joinedConversationEventMock)

getTokenMock = jest.fn().mockReturnValue(TOKEN)
getParticipantIdentifierMock = jest.fn().mockReturnValue({
attendeeId: 1,
})
Expand All @@ -636,6 +638,7 @@ describe('participantsStore', () => {
inCall: PARTICIPANT.CALL_FLAG.DISCONNECTED,
}

testStoreConfig.getters.getToken = () => getTokenMock
testStoreConfig.getters.getParticipantIdentifier = () => getParticipantIdentifierMock
testStoreConfig.actions.setCurrentParticipant = jest.fn()
testStoreConfig.actions.addConversation = jest.fn().mockImplementation((context) => {
Expand Down Expand Up @@ -683,8 +686,8 @@ describe('participantsStore', () => {

expect(joinConversation).toHaveBeenCalledWith({ token: TOKEN, forceJoin: true })

expect(testStoreConfig.actions.setCurrentParticipant).toHaveBeenCalledWith(expect.anything(), participantData)
expect(testStoreConfig.actions.addConversation).toHaveBeenCalledWith(expect.anything(), participantData)
expect(testStoreConfig.actions.setCurrentParticipant).toHaveBeenCalledWith(expect.anything(), updatedParticipantData)
expect(testStoreConfig.actions.addConversation).toHaveBeenCalledWith(expect.anything(), updatedParticipantData)

expect(getParticipantIdentifierMock).toHaveBeenCalled()

Expand Down

0 comments on commit e8dbc00

Please sign in to comment.