diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 15:09:08 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 15:09:08 +0000 |
commit | b3a736ed88a1db0391cd9881e70b987bab7d89d1 (patch) | |
tree | a91ca3a06abd4c3412775ac3c49b11e3151df2be /spec/frontend/ide/stores | |
parent | 5366964a10484c2783a646b35a6da9eece01b242 (diff) | |
download | gitlab-ce-b3a736ed88a1db0391cd9881e70b987bab7d89d1.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/stores')
-rw-r--r-- | spec/frontend/ide/stores/getters_spec.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/frontend/ide/stores/getters_spec.js b/spec/frontend/ide/stores/getters_spec.js index 21c5e886738..011be95c1d2 100644 --- a/spec/frontend/ide/stores/getters_spec.js +++ b/spec/frontend/ide/stores/getters_spec.js @@ -2,6 +2,8 @@ import * as getters from '~/ide/stores/getters'; import { createStore } from '~/ide/stores'; import { file } from '../helpers'; +const TEST_PROJECT_ID = 'test_project'; + describe('IDE store getters', () => { let localState; let localStore; @@ -398,4 +400,38 @@ describe('IDE store getters', () => { }, ); }); + + describe('findProjectPermissions', () => { + it('returns false if project not found', () => { + expect(localStore.getters.findProjectPermissions(TEST_PROJECT_ID)).toEqual({}); + }); + + it('finds permission in given project', () => { + const userPermissions = { + readMergeRequest: true, + createMergeRequestsIn: false, + }; + + localState.projects[TEST_PROJECT_ID] = { userPermissions }; + + expect(localStore.getters.findProjectPermissions(TEST_PROJECT_ID)).toBe(userPermissions); + }); + }); + + describe.each` + getterName | permissionKey + ${'canReadMergeRequests'} | ${'readMergeRequest'} + ${'canCreateMergeRequests'} | ${'createMergeRequestIn'} + `('$getterName', ({ getterName, permissionKey }) => { + it.each([true, false])('finds permission for current project (%s)', val => { + localState.projects[TEST_PROJECT_ID] = { + userPermissions: { + [permissionKey]: val, + }, + }; + localState.currentProjectId = TEST_PROJECT_ID; + + expect(localStore.getters[getterName]).toBe(val); + }); + }); }); |