diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /spec/frontend/api/tags_api_spec.js | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'spec/frontend/api/tags_api_spec.js')
-rw-r--r-- | spec/frontend/api/tags_api_spec.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/frontend/api/tags_api_spec.js b/spec/frontend/api/tags_api_spec.js new file mode 100644 index 00000000000..a7436bf6a50 --- /dev/null +++ b/spec/frontend/api/tags_api_spec.js @@ -0,0 +1,37 @@ +import MockAdapter from 'axios-mock-adapter'; +import * as tagsApi from '~/api/tags_api'; +import axios from '~/lib/utils/axios_utils'; +import httpStatus from '~/lib/utils/http_status'; + +describe('~/api/tags_api.js', () => { + let mock; + let originalGon; + + const projectId = 1; + + beforeEach(() => { + mock = new MockAdapter(axios); + + originalGon = window.gon; + window.gon = { api_version: 'v7' }; + }); + + afterEach(() => { + mock.restore(); + window.gon = originalGon; + }); + + describe('getTag', () => { + it('fetches a tag of a given tag name of a particular project', () => { + const tagName = 'tag-name'; + const expectedUrl = `/api/v7/projects/${projectId}/repository/tags/${tagName}`; + mock.onGet(expectedUrl).reply(httpStatus.OK, { + name: tagName, + }); + + return tagsApi.getTag(projectId, tagName).then(({ data }) => { + expect(data.name).toBe(tagName); + }); + }); + }); +}); |