jdalrymple 6d5a4b92b0
Typescript Support (#183)
* chore: Introduce typescript 
* chore: Remove lodash.pick, use native js instead
* chore: Add tslint and extend Airbnb ruleset
* chore: Remove Babel Dependency, replace build steps with tsc
* chore: change target for modern env from es2017 to es6 (async/await should be transpiled to downlevel js)
* chore(package): Updating packages
* fix: Fix error while throwing an error in RequestHelper (#156)
* feat: Support rejectUnauthorized parameter (#164)
* feat: Adding project archive abilities
* fix(test): Application settings API updated (#177)
* fix: Removing token requirement (#176)
* chore: Removing npmignore and using files instead.
* fix: obey rate limits for all request types correctly (#170)
* fix: Camel casing broke the body params
2018-09-05 11:22:28 -04:00

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 user supplies 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');
});
});