debian-mirror-gitlab/spec/frontend/groups/service/groups_service_spec.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-03-11 19:13:27 +05:30
import GroupsService from '~/groups/service/groups_service';
2019-12-04 20:38:33 +05:30
import axios from '~/lib/utils/axios_utils';
2018-03-17 18:26:18 +05:30
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', () => {
2020-05-24 23:13:21 +05:30
jest.spyOn(axios, 'get').mockResolvedValue();
2019-12-04 20:38:33 +05:30
const params = {
2018-03-17 18:26:18 +05:30
page: 2,
filter: 'git',
sort: 'created_asc',
archived: true,
};
service.getGroups(55, 2, 'git', 'created_asc', true);
2018-12-13 13:39:08 +05:30
2019-12-04 20:38:33 +05:30
expect(axios.get).toHaveBeenCalledWith(mockEndpoint, { params: { parent_id: 55 } });
2018-03-17 18:26:18 +05:30
service.getGroups(null, 2, 'git', 'created_asc', true);
2018-12-13 13:39:08 +05:30
2019-12-04 20:38:33 +05:30
expect(axios.get).toHaveBeenCalledWith(mockEndpoint, { params });
2018-03-17 18:26:18 +05:30
});
});
describe('leaveGroup', () => {
it('should return promise for `DELETE` request on provided endpoint', () => {
2020-05-24 23:13:21 +05:30
jest.spyOn(axios, 'delete').mockResolvedValue();
2018-03-17 18:26:18 +05:30
service.leaveGroup(mockParentGroupItem.leavePath);
2018-12-13 13:39:08 +05:30
2019-12-04 20:38:33 +05:30
expect(axios.delete).toHaveBeenCalledWith(mockParentGroupItem.leavePath);
2018-03-17 18:26:18 +05:30
});
});
});