mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
Update typing to specify that path or name must be passed (#796)
This commit is contained in:
parent
f3638aecfa
commit
1cec2d736c
@ -61,7 +61,10 @@ export class Projects extends BaseService {
|
||||
return RequestHelper.post(this, `projects/${pId}/archive`, options);
|
||||
}
|
||||
|
||||
create({ userId, ...options }: { userId?: number } & BaseRequestOptions) {
|
||||
create({
|
||||
userId,
|
||||
...options
|
||||
}: ({ name: string } | { path: string }) & { userId?: number } & BaseRequestOptions) {
|
||||
const url = userId ? `projects/user/${encodeURIComponent(userId)}` : 'projects';
|
||||
|
||||
return RequestHelper.post(this, url, options);
|
||||
|
||||
@ -56,28 +56,28 @@ describe('Projects.archive', () => {
|
||||
|
||||
describe('Projects.create', () => {
|
||||
it('should request POST /projects when userId undefined', async () => {
|
||||
await service.create({ title: 'test proj' });
|
||||
await service.create({ name: 'test proj' });
|
||||
|
||||
expect(RequestHelper.post).toHaveBeenCalledWith(service, 'projects', {
|
||||
title: 'test proj',
|
||||
name: 'test proj',
|
||||
});
|
||||
});
|
||||
|
||||
it('should request POST /projects/user/:id when userId defined', async () => {
|
||||
await service.create({ userId: 2, title: 'test proj' });
|
||||
await service.create({ userId: 2, name: 'test proj' });
|
||||
|
||||
expect(RequestHelper.post).toHaveBeenCalledWith(service, 'projects/user/2', {
|
||||
title: 'test proj',
|
||||
name: 'test proj',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Projects.edit', () => {
|
||||
it('should request PUT /projects', async () => {
|
||||
await service.edit(12, { title: 'test proj 2' });
|
||||
await service.edit(12, { name: 'test proj 2' });
|
||||
|
||||
expect(RequestHelper.put).toHaveBeenCalledWith(service, 'projects/12', {
|
||||
title: 'test proj 2',
|
||||
name: 'test proj 2',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user