mirror of
https://github.com/jdalrymple/gitbeaker.git
synced 2026-01-25 16:04:01 +00:00
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import { BaseService } from '../../../src/infrastructure';
|
|
|
|
describe('Creation of BaseService instance', () => {
|
|
test('Url defaults to https://gitlab.com/api/v4', async () => {
|
|
const service = new BaseService({ token: 'test' });
|
|
|
|
expect(service.url).toBe('https://gitlab.com/api/v4');
|
|
});
|
|
|
|
test('Use the Oauth Token when a given both a Private Token and a Oauth Token', async () => {
|
|
const service = new BaseService({ token: 'test', oauthToken: '1234' });
|
|
|
|
expect(service.headers['private-token']).toBeUndefined();
|
|
expect(service.headers.authorization).toBe('Bearer 1234');
|
|
});
|
|
|
|
test('Custom url still appends api and version number to url', async () => {
|
|
const service = new BaseService({ url: 'https://testing.com', token: 'test' });
|
|
|
|
expect(service.url).toBe('https://testing.com/api/v4');
|
|
});
|
|
|
|
test('Oauth token adds to authorization header as a bearer token', async () => {
|
|
const service = new BaseService({ url: 'https://testing.com', oauthToken: '1234' });
|
|
|
|
expect(service.headers.authorization).toBe('Bearer 1234');
|
|
});
|
|
|
|
test('Private token adds to private-token header', async () => {
|
|
const service = new BaseService({ url: 'https://testing.com', token: '1234' });
|
|
|
|
expect(service.headers['private-token']).toBe('1234');
|
|
});
|
|
|
|
test('API version should be modified', async () => {
|
|
const service = new BaseService({ url: 'https://testing.com', token: '1234', version: 'v3' });
|
|
|
|
expect(service.url).toBe('https://testing.com/api/v3');
|
|
});
|
|
});
|