Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tags_api_spec.js « api « frontend « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0a1177d4f608fa2dea5d44596d729f4f51152c81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import MockAdapter from 'axios-mock-adapter';
import * as tagsApi from '~/api/tags_api';
import axios from '~/lib/utils/axios_utils';
import { HTTP_STATUS_OK } from '~/lib/utils/http_status';

describe('~/api/tags_api.js', () => {
  let mock;

  const projectId = 1;

  beforeEach(() => {
    mock = new MockAdapter(axios);

    window.gon = { api_version: 'v7' };
  });

  afterEach(() => {
    mock.restore();
  });

  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(HTTP_STATUS_OK, {
        name: tagName,
      });

      return tagsApi.getTag(projectId, tagName).then(({ data }) => {
        expect(data.name).toBe(tagName);
      });
    });
  });
});