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:
Diffstat (limited to 'spec/frontend/api/projects_api_spec.js')
-rw-r--r--spec/frontend/api/projects_api_spec.js25
1 files changed, 10 insertions, 15 deletions
diff --git a/spec/frontend/api/projects_api_spec.js b/spec/frontend/api/projects_api_spec.js
index 2d4ed39dad0..4ceed885e6e 100644
--- a/spec/frontend/api/projects_api_spec.js
+++ b/spec/frontend/api/projects_api_spec.js
@@ -7,23 +7,17 @@ import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
describe('~/api/projects_api.js', () => {
let mock;
- let originalGon;
const projectId = 1;
- const setfullPathProjectSearch = (value) => {
- window.gon.features.fullPathProjectSearch = value;
- };
beforeEach(() => {
mock = new MockAdapter(axios);
- originalGon = window.gon;
- window.gon = { api_version: 'v7', features: { fullPathProjectSearch: true } };
+ window.gon = { api_version: 'v7' };
});
afterEach(() => {
mock.restore();
- window.gon = originalGon;
});
describe('getProjects', () => {
@@ -71,17 +65,18 @@ describe('~/api/projects_api.js', () => {
expect(data.data).toEqual(expectedProjects);
});
});
+ });
- it('does not search namespaces if fullPathProjectSearch is disabled', () => {
- setfullPathProjectSearch(false);
- const expectedParams = { params: { per_page: 20, search: 'group/project1', simple: true } };
- const query = 'group/project1';
+ describe('createProject', () => {
+ it('posts to the correct URL and returns the data', () => {
+ const body = { name: 'test project' };
+ const expectedUrl = '/api/v7/projects.json';
+ const expectedRes = { id: 999, name: 'test project' };
- mock.onGet(expectedUrl).reply(HTTP_STATUS_OK, { data: expectedProjects });
+ mock.onPost(expectedUrl, body).replyOnce(HTTP_STATUS_OK, { data: expectedRes });
- return projectsApi.getProjects(query, options).then(({ data }) => {
- expect(axios.get).toHaveBeenCalledWith(expectedUrl, expectedParams);
- expect(data.data).toEqual(expectedProjects);
+ return projectsApi.createProject(body).then(({ data }) => {
+ expect(data).toStrictEqual(expectedRes);
});
});
});