diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/frontend/api/user_api_spec.js | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/frontend/api/user_api_spec.js')
-rw-r--r-- | spec/frontend/api/user_api_spec.js | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/spec/frontend/api/user_api_spec.js b/spec/frontend/api/user_api_spec.js index ba6b73e8c1a..9e901cf0f71 100644 --- a/spec/frontend/api/user_api_spec.js +++ b/spec/frontend/api/user_api_spec.js @@ -1,8 +1,13 @@ import MockAdapter from 'axios-mock-adapter'; -import { followUser, unfollowUser, associationsCount } from '~/api/user_api'; +import { followUser, unfollowUser, associationsCount, updateUserStatus } from '~/api/user_api'; import axios from '~/lib/utils/axios_utils'; -import { associationsCount as associationsCountData } from 'jest/admin/users/mock_data'; +import { + associationsCount as associationsCountData, + userStatus as mockUserStatus, +} from 'jest/admin/users/mock_data'; +import { AVAILABILITY_STATUS } from '~/set_status_modal/constants'; +import { timeRanges } from '~/vue_shared/constants'; describe('~/api/user_api', () => { let axiosMock; @@ -62,4 +67,30 @@ describe('~/api/user_api', () => { expect(axiosMock.history.get[0].url).toBe(expectedUrl); }); }); + + describe('updateUserStatus', () => { + it('calls correct URL and returns expected response', async () => { + const expectedUrl = '/api/v4/user/status'; + const expectedData = { + emoji: 'basketball', + message: 'test', + availability: AVAILABILITY_STATUS.BUSY, + clear_status_after: timeRanges[0].shortcut, + }; + const expectedResponse = { data: mockUserStatus }; + + axiosMock.onPatch(expectedUrl).replyOnce(200, expectedResponse); + + await expect( + updateUserStatus({ + emoji: 'basketball', + message: 'test', + availability: AVAILABILITY_STATUS.BUSY, + clearStatusAfter: timeRanges[0].shortcut, + }), + ).resolves.toEqual(expect.objectContaining({ data: expectedResponse })); + expect(axiosMock.history.patch[0].url).toBe(expectedUrl); + expect(JSON.parse(axiosMock.history.patch[0].data)).toEqual(expectedData); + }); + }); }); |