diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-28 15:07:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-09-28 15:07:50 +0300 |
commit | eb3a23aaaa99ef8ae08c7b440fad676e3c71a1af (patch) | |
tree | bb74f64f73f4a20d4b4e3443c3e7defd4733a78d /spec/frontend/api | |
parent | f3cfb235c76426ce5a18003bb80ba625097bf1d0 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/api')
-rw-r--r-- | spec/frontend/api/projects_api_spec.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/frontend/api/projects_api_spec.js b/spec/frontend/api/projects_api_spec.js index 8f40b557e1f..8459021421f 100644 --- a/spec/frontend/api/projects_api_spec.js +++ b/spec/frontend/api/projects_api_spec.js @@ -1,5 +1,7 @@ import MockAdapter from 'axios-mock-adapter'; +import getTransferLocationsResponse from 'test_fixtures/api/projects/transfer_locations_page_1.json'; import * as projectsApi from '~/api/projects_api'; +import { DEFAULT_PER_PAGE } from '~/api'; import axios from '~/lib/utils/axios_utils'; describe('~/api/projects_api.js', () => { @@ -59,4 +61,25 @@ describe('~/api/projects_api.js', () => { }); }); }); + + describe('getTransferLocations', () => { + beforeEach(() => { + jest.spyOn(axios, 'get'); + }); + + it('retrieves transfer locations from the correct URL and returns them in the response data', async () => { + const params = { page: 1 }; + const expectedUrl = '/api/v7/projects/1/transfer_locations'; + + mock.onGet(expectedUrl).replyOnce(200, { data: getTransferLocationsResponse }); + + await expect(projectsApi.getTransferLocations(projectId, params)).resolves.toMatchObject({ + data: { data: getTransferLocationsResponse }, + }); + + expect(axios.get).toHaveBeenCalledWith(expectedUrl, { + params: { ...params, per_page: DEFAULT_PER_PAGE }, + }); + }); + }); }); |