Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 18:09:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 18:09:08 +0300
commitb3a736ed88a1db0391cd9881e70b987bab7d89d1 (patch)
treea91ca3a06abd4c3412775ac3c49b11e3151df2be /spec/frontend/ide/services
parent5366964a10484c2783a646b35a6da9eece01b242 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/services')
-rw-r--r--spec/frontend/ide/services/index_spec.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/spec/frontend/ide/services/index_spec.js b/spec/frontend/ide/services/index_spec.js
index 83a3cfe618b..55f174f4663 100644
--- a/spec/frontend/ide/services/index_spec.js
+++ b/spec/frontend/ide/services/index_spec.js
@@ -2,11 +2,17 @@ import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import services from '~/ide/services';
import Api from '~/api';
+import gqClient from '~/ide/services/gql';
import { escapeFileUrl } from '~/lib/utils/url_utility';
+import getUserPermissions from '~/ide/queries/getUserPermissions.query.graphql';
+import { projectData } from '../mock_data';
jest.mock('~/api');
+jest.mock('~/ide/services/gql');
-const TEST_PROJECT_ID = 'alice/wonderland';
+const TEST_NAMESPACE = 'alice';
+const TEST_PROJECT = 'wonderland';
+const TEST_PROJECT_ID = `${TEST_NAMESPACE}/${TEST_PROJECT}`;
const TEST_BRANCH = 'master-patch-123';
const TEST_COMMIT_SHA = '123456789';
const TEST_FILE_PATH = 'README2.md';
@@ -111,4 +117,27 @@ describe('IDE services', () => {
},
);
});
+
+ describe('getProjectData', () => {
+ it('combines gql and API requests', () => {
+ const gqlProjectData = {
+ userPermissions: {
+ bogus: true,
+ },
+ };
+ Api.project.mockReturnValue(Promise.resolve({ data: { ...projectData } }));
+ gqClient.query.mockReturnValue(Promise.resolve({ data: { project: gqlProjectData } }));
+
+ return services.getProjectData(TEST_NAMESPACE, TEST_PROJECT).then(response => {
+ expect(response).toEqual({ data: { ...projectData, ...gqlProjectData } });
+ expect(Api.project).toHaveBeenCalledWith(TEST_PROJECT_ID);
+ expect(gqClient.query).toHaveBeenCalledWith({
+ query: getUserPermissions,
+ variables: {
+ projectPath: TEST_PROJECT_ID,
+ },
+ });
+ });
+ });
+ });
});