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

groups_service_spec.js « service « groups « javascripts « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 45db962a1efa636630842d55b6f34baad3b0a959 (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
35
36
37
38
39
40
41
42
import axios from '~/lib/utils/axios_utils';

import GroupsService from '~/groups/service/groups_service';
import { mockEndpoint, mockParentGroupItem } from '../mock_data';

describe('GroupsService', () => {
  let service;

  beforeEach(() => {
    service = new GroupsService(mockEndpoint);
  });

  describe('getGroups', () => {
    it('should return promise for `GET` request on provided endpoint', () => {
      spyOn(axios, 'get').and.stub();
      const params = {
        page: 2,
        filter: 'git',
        sort: 'created_asc',
        archived: true,
      };

      service.getGroups(55, 2, 'git', 'created_asc', true);

      expect(axios.get).toHaveBeenCalledWith(mockEndpoint, { params: { parent_id: 55 } });

      service.getGroups(null, 2, 'git', 'created_asc', true);

      expect(axios.get).toHaveBeenCalledWith(mockEndpoint, { params });
    });
  });

  describe('leaveGroup', () => {
    it('should return promise for `DELETE` request on provided endpoint', () => {
      spyOn(axios, 'delete').and.stub();

      service.leaveGroup(mockParentGroupItem.leavePath);

      expect(axios.delete).toHaveBeenCalledWith(mockParentGroupItem.leavePath);
    });
  });
});