diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/frontend/api_spec.js | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/frontend/api_spec.js')
-rw-r--r-- | spec/frontend/api_spec.js | 68 |
1 files changed, 54 insertions, 14 deletions
diff --git a/spec/frontend/api_spec.js b/spec/frontend/api_spec.js index 139128e6d4a..f708d8c7728 100644 --- a/spec/frontend/api_spec.js +++ b/spec/frontend/api_spec.js @@ -116,6 +116,24 @@ describe('Api', () => { }); }); }); + + describe('deleteProjectPackageFile', () => { + const packageFileId = 'package_file_id'; + + it('delete a package', () => { + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${projectId}/packages/${packageId}/package_files/${packageFileId}`; + + jest.spyOn(axios, 'delete'); + mock.onDelete(expectedUrl).replyOnce(httpStatus.OK, true); + + return Api.deleteProjectPackageFile(projectId, packageId, packageFileId).then( + ({ data }) => { + expect(data).toEqual(true); + expect(axios.delete).toHaveBeenCalledWith(expectedUrl); + }, + ); + }); + }); }); describe('container registry', () => { @@ -1503,33 +1521,55 @@ describe('Api', () => { 'Content-Type': 'application/json', }; - describe('when usage data increment unique users is called with feature flag disabled', () => { + describe('when user is set', () => { beforeEach(() => { - gon.features = { ...gon.features, usageDataApi: false }; + window.gon.current_user_id = 1; }); - it('returns null', () => { - jest.spyOn(axios, 'post'); - mock.onPost(expectedUrl).replyOnce(httpStatus.OK, true); + describe('when usage data increment unique users is called with feature flag disabled', () => { + beforeEach(() => { + gon.features = { ...gon.features, usageDataApi: false }; + }); - expect(axios.post).toHaveBeenCalledTimes(0); - expect(Api.trackRedisHllUserEvent(event)).toEqual(null); + it('returns null and does not call the endpoint', () => { + jest.spyOn(axios, 'post'); + + const result = Api.trackRedisHllUserEvent(event); + + expect(result).toEqual(null); + expect(axios.post).toHaveBeenCalledTimes(0); + }); + }); + + describe('when usage data increment unique users is called', () => { + beforeEach(() => { + gon.features = { ...gon.features, usageDataApi: true }; + }); + + it('resolves the Promise', () => { + jest.spyOn(axios, 'post'); + mock.onPost(expectedUrl, { event }).replyOnce(httpStatus.OK, true); + + return Api.trackRedisHllUserEvent(event).then(({ data }) => { + expect(data).toEqual(true); + expect(axios.post).toHaveBeenCalledWith(expectedUrl, postData, { headers }); + }); + }); }); }); - describe('when usage data increment unique users is called', () => { + describe('when user is not set and feature flag enabled', () => { beforeEach(() => { gon.features = { ...gon.features, usageDataApi: true }; }); - it('resolves the Promise', () => { + it('returns null and does not call the endpoint', () => { jest.spyOn(axios, 'post'); - mock.onPost(expectedUrl, { event }).replyOnce(httpStatus.OK, true); - return Api.trackRedisHllUserEvent(event).then(({ data }) => { - expect(data).toEqual(true); - expect(axios.post).toHaveBeenCalledWith(expectedUrl, postData, { headers }); - }); + const result = Api.trackRedisHllUserEvent(event); + + expect(result).toEqual(null); + expect(axios.post).toHaveBeenCalledTimes(0); }); }); }); |