diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 21:08:53 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-14 21:08:53 +0300 |
commit | 5b62f8e3ee531f63ce3c49cae03e2a618ba51615 (patch) | |
tree | 2d2553232fe0663957ee4d1054211cc71cb07679 /spec/frontend/api | |
parent | cdb41961fd2bc233d36c5b30f89d087c2efa9818 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/api')
-rw-r--r-- | spec/frontend/api/user_api_spec.js | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/spec/frontend/api/user_api_spec.js b/spec/frontend/api/user_api_spec.js index 6636d77a09b..a879c229581 100644 --- a/spec/frontend/api/user_api_spec.js +++ b/spec/frontend/api/user_api_spec.js @@ -1,6 +1,13 @@ import MockAdapter from 'axios-mock-adapter'; -import { followUser, unfollowUser, associationsCount, updateUserStatus } from '~/api/user_api'; +import projects from 'test_fixtures/api/users/projects/get.json'; +import { + followUser, + unfollowUser, + associationsCount, + updateUserStatus, + getUserProjects, +} from '~/api/user_api'; import axios from '~/lib/utils/axios_utils'; import { HTTP_STATUS_OK } from '~/lib/utils/http_status'; import { @@ -91,4 +98,18 @@ describe('~/api/user_api', () => { expect(JSON.parse(axiosMock.history.patch[0].data)).toEqual(expectedData); }); }); + + describe('getUserProjects', () => { + it('calls correct URL and returns expected response', async () => { + const expectedUrl = '/api/v4/users/1/projects'; + const expectedResponse = { data: projects }; + + axiosMock.onGet(expectedUrl).replyOnce(HTTP_STATUS_OK, expectedResponse); + + await expect(getUserProjects(1)).resolves.toEqual( + expect.objectContaining({ data: expectedResponse }), + ); + expect(axiosMock.history.get[0].url).toBe(expectedUrl); + }); + }); }); |