2019-12-04 20:38:33 +05:30
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
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', () => {
|
2019-12-04 20:38:33 +05:30
|
|
|
spyOn(axios, 'get').and.stub();
|
|
|
|
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', () => {
|
2019-12-04 20:38:33 +05:30
|
|
|
spyOn(axios, 'delete').and.stub();
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|