-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0db094
commit 366951a
Showing
8 changed files
with
474 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { RequestHelper } from '../../../src/infrastructure'; | ||
import { GeoSites } from '../../../src'; | ||
|
||
jest.mock( | ||
'../../../src/infrastructure/RequestHelper', | ||
() => require('../../__mocks__/RequestHelper').default, | ||
); | ||
|
||
let service: GeoSites; | ||
|
||
beforeEach(() => { | ||
service = new GeoSites({ | ||
requesterFn: jest.fn(), | ||
token: 'abcdefg', | ||
}); | ||
}); | ||
|
||
describe('GeoSites.all', () => { | ||
it('should request GET /geo_sites', async () => { | ||
await service.all(); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith(service, 'geo_sites', undefined); | ||
}); | ||
}); | ||
|
||
describe('GeoSites.create', () => { | ||
it('should request POST /geo_sites', async () => { | ||
await service.create('name', 'url'); | ||
|
||
expect(RequestHelper.post()).toHaveBeenCalledWith(service, 'geo_sites', { | ||
name: 'name', | ||
url: 'url', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('GeoSites.edit', () => { | ||
it('should request PUT /geo_sites/:id', async () => { | ||
await service.edit(1); | ||
|
||
expect(RequestHelper.put()).toHaveBeenCalledWith(service, 'geo_sites/1', undefined); | ||
}); | ||
|
||
it('should request PUT /geo_sites/:id with options', async () => { | ||
await service.edit(1, { internalUrl: 'url' }); | ||
|
||
expect(RequestHelper.put()).toHaveBeenCalledWith(service, 'geo_sites/1', { | ||
internalUrl: 'url', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('GeoSites.allFailures', () => { | ||
it('should request POST /geo_sites/current/failures', async () => { | ||
await service.allFailures(); | ||
|
||
expect(RequestHelper.post()).toHaveBeenCalledWith( | ||
service, | ||
'geo_sites/current/failures', | ||
undefined, | ||
); | ||
}); | ||
}); | ||
|
||
describe('GeoSites.repair', () => { | ||
it('should request POST /geo_sites/:id/repair', async () => { | ||
await service.repair(1); | ||
|
||
expect(RequestHelper.post()).toHaveBeenCalledWith(service, 'geo_sites/1/repair', undefined); | ||
}); | ||
}); | ||
|
||
describe('GeoSites.show', () => { | ||
it('should request GET /geo_sites/:id', async () => { | ||
await service.show(1); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith(service, 'geo_sites/1', undefined); | ||
}); | ||
}); | ||
|
||
describe('GeoSites.showStatus', () => { | ||
it('should request GET /geo_sites/:id/status', async () => { | ||
await service.showStatus(1); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith(service, 'geo_sites/1/status', undefined); | ||
}); | ||
}); | ||
|
||
describe('GeoSites.allStatuses', () => { | ||
it('should request GET /geo_sites/statuses', async () => { | ||
await service.allStatuses(); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith(service, 'geo_sites/statuses', undefined); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { RequestHelper } from '../../../src/infrastructure'; | ||
import { GitlabPages } from '../../../src'; | ||
|
||
jest.mock( | ||
'../../../src/infrastructure/RequestHelper', | ||
() => require('../../__mocks__/RequestHelper').default, | ||
); | ||
|
||
let service: GitlabPages; | ||
|
||
beforeEach(() => { | ||
service = new GitlabPages({ | ||
requesterFn: jest.fn(), | ||
token: 'abcdefg', | ||
}); | ||
}); | ||
|
||
describe('GitlabPages.remove', () => { | ||
it('should request DEL /projects/1/pages', async () => { | ||
await service.remove(1); | ||
|
||
expect(RequestHelper.del()).toHaveBeenCalledWith(service, 'projects/1/pages', undefined); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { GroupEpicBoards } from '../../../src/resources'; | ||
import { RequestHelper } from '../../../src/infrastructure'; | ||
|
||
jest.mock( | ||
'../../../src/infrastructure/RequestHelper', | ||
() => require('../../__mocks__/RequestHelper').default, | ||
); | ||
|
||
let service: GroupEpicBoards; | ||
|
||
beforeEach(() => { | ||
service = new GroupEpicBoards({ | ||
requesterFn: jest.fn(), | ||
token: 'abcdefg', | ||
}); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('GroupEpicBoards.all', () => { | ||
it('should call the correct url with a group id', async () => { | ||
await service.all(1); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith(service, 'groups/1/epic_boards', undefined); | ||
}); | ||
}); | ||
|
||
describe('GroupEpicBoards.allLists', () => { | ||
it('should call the correct url with a group id and board id', async () => { | ||
await service.allLists('5', 6); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith( | ||
service, | ||
'groups/5/epic_boards/6/lists', | ||
undefined, | ||
); | ||
}); | ||
}); | ||
|
||
describe('GroupEpicBoards.show', () => { | ||
it('should call the correct url with a group id and board id', async () => { | ||
await service.show('5', 6); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith(service, 'groups/5/epic_boards/6', undefined); | ||
}); | ||
}); | ||
|
||
describe('GroupEpicBoards.showList', () => { | ||
it('should call the correct url with a group id, board id and list id', async () => { | ||
await service.showList('5', 6, 7); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith( | ||
service, | ||
'groups/5/epic_boards/6/lists/7', | ||
undefined, | ||
); | ||
}); | ||
}); |
63 changes: 63 additions & 0 deletions
63
packages/core/test/unit/resources/InstanceLevelCICDVariables.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { RequestHelper } from '../../../src/infrastructure'; | ||
import { InstanceLevelCICDVariables } from '../../../src'; | ||
|
||
jest.mock( | ||
'../../../src/infrastructure/RequestHelper', | ||
() => require('../../__mocks__/RequestHelper').default, | ||
); | ||
|
||
let service: InstanceLevelCICDVariables; | ||
|
||
beforeEach(() => { | ||
service = new InstanceLevelCICDVariables({ | ||
requesterFn: jest.fn(), | ||
token: 'abcdefg', | ||
}); | ||
}); | ||
|
||
describe('InstanceLevelCICDVariables.all', () => { | ||
it('should request GET admin/ci/variables', async () => { | ||
await service.all(); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith(service, 'admin/ci/variables', undefined); | ||
}); | ||
}); | ||
|
||
describe('InstanceLevelCICDVariables.create', () => { | ||
it('should request POST admin/ci/variables', async () => { | ||
await service.create('key', 'value', { raw: false }); | ||
|
||
expect(RequestHelper.post()).toHaveBeenCalledWith(service, 'admin/ci/variables', { | ||
key: 'key', | ||
value: 'value', | ||
raw: false, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('InstanceLevelCICDVariables.edit', () => { | ||
it('should request PUT admin/ci/variables/:key', async () => { | ||
await service.edit('key', 'value', { raw: false }); | ||
|
||
expect(RequestHelper.post()).toHaveBeenCalledWith(service, 'admin/ci/variables/key', { | ||
value: 'value', | ||
raw: false, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('InstanceLevelCICDVariables.remove', () => { | ||
it('should request DEL admin/ci/variables/:key', async () => { | ||
await service.remove('key'); | ||
|
||
expect(RequestHelper.del()).toHaveBeenCalledWith(service, 'admin/ci/variables/key', undefined); | ||
}); | ||
}); | ||
|
||
describe('InstanceLevelCICDVariables.show', () => { | ||
it('should request GET admin/ci/variables/:name', async () => { | ||
await service.show('key'); | ||
|
||
expect(RequestHelper.get()).toHaveBeenCalledWith(service, 'admin/ci/variables/key', undefined); | ||
}); | ||
}); |
Oops, something went wrong.