diff options
author | marco <marcoambrosini@pm.me> | 2021-10-22 16:20:30 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-11-04 18:34:21 +0300 |
commit | fb7ba9e7a394e652cc7233f33c0d2d46bda9f61f (patch) | |
tree | 1c09b10aa0c082a3b0ad2e425b21efa696616fe9 /src | |
parent | 48132b305aace9a8fbeaf450a67510c2b5e86289 (diff) |
Add tests for store actions
Signed-off-by: marco <marcoambrosini@pm.me>
Diffstat (limited to 'src')
-rw-r--r-- | src/store/conversationsStore.spec.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/store/conversationsStore.spec.js b/src/store/conversationsStore.spec.js index 770026dae..83f38785b 100644 --- a/src/store/conversationsStore.spec.js +++ b/src/store/conversationsStore.spec.js @@ -24,6 +24,8 @@ import { fetchConversation, fetchConversations, deleteConversation, + setConversationPermissions, + setCallPermissions, } from '../services/conversationsService' jest.mock('../services/conversationsService', () => ({ @@ -42,6 +44,8 @@ jest.mock('../services/conversationsService', () => ({ fetchConversation: jest.fn(), fetchConversations: jest.fn(), deleteConversation: jest.fn(), + setConversationPermissions: jest.fn(), + setCallPermissions: jest.fn(), })) describe('conversationsStore', () => { @@ -51,6 +55,7 @@ describe('conversationsStore', () => { let localVue = null let store = null let addParticipantOnceAction = null + const permissions = PARTICIPANT.PERMISSIONS.MAX_CUSTOM beforeEach(() => { localVue = createLocalVue() @@ -65,6 +70,8 @@ describe('conversationsStore', () => { attendeeId: 'attendee-id-1', actorType: ATTENDEE.ACTOR_TYPE.USERS, actorId: 'actor-id', + defaultPermissions: PARTICIPANT.PERMISSIONS.CUSTOM, + callPermissions: PARTICIPANT.PERMISSIONS.CUSTOM, } testStoreConfig = cloneDeep(storeConfig) @@ -611,4 +618,24 @@ describe('conversationsStore', () => { expect(addedConversation).toBe(newConversation) }) }) + + test('sets default permissions for a conversation', async () => { + expect(store.getters.selectedParticipants).toStrictEqual([]) + + await store.dispatch('setConversationPermissions', { token: testToken, permissions }) + + expect(setConversationPermissions).toHaveBeenCalledWith(testToken, permissions) + + expect(store.getters.conversation(testToken).defaultPermissions).toBe(permissions) + }) + + test('sets default permissions for a call', async () => { + expect(store.getters.selectedParticipants).toStrictEqual([]) + + await store.dispatch('setCallPermissions', { token: testToken, permissions }) + + expect(setCallPermissions).toHaveBeenCalledWith(testToken, permissions) + + expect(store.getters.conversation(testToken).callPermissions).toBe(permissions) + }) }) |