diff --git a/.eslintrc.yaml b/.eslintrc.yml similarity index 100% rename from .eslintrc.yaml rename to .eslintrc.yml diff --git a/.jestrc.yaml b/.jestrc.yaml deleted file mode 100644 index a334eacd..00000000 --- a/.jestrc.yaml +++ /dev/null @@ -1,5 +0,0 @@ -coverageDirectory: "./coverage/" -collectCoverage: true -testRegex: "(/__tests__/.*|/tests/.*(\\.|/)(test|spec))\\.jsx?$" -reporters: - - "jest-tap-reporter" \ No newline at end of file diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 00000000..3836c083 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,12 @@ +// coverageDirectory: "./coverage/" +// collectCoverage: true +// testRegex: "(/__tests__/.*|/tests/.*(\\.|/)(test|spec))\\.jsx?$" +// reporters: +// - "jest-tap-reporter" + +{ + "coverageDirectory": "./coverage/", + "collectCoverage": true, + "testRegex": "(/__tests__/.*|/tests/.*(\\.|/)(test|spec))\\.jsx?$", + "reporters": ["jest-tap-reporter" ] +} \ No newline at end of file diff --git a/tests/infratructure/BaseService.js b/tests/infratructure/BaseService.js new file mode 100644 index 00000000..67fdb638 --- /dev/null +++ b/tests/infratructure/BaseService.js @@ -0,0 +1,29 @@ +import { BaseService } from '../../dist/latest/infrastructure'; + +test('If a token or oauthToken is not passed, throw an error', async ()=> { + expect(new BaseService()).toThrowError('`token` (private-token) or `oauth_token` is mandatory') +}); + +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('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'); +}); diff --git a/tests/infratructure/RequestHelper.js b/tests/infratructure/RequestHelper.js deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/services/ApplicationSettings.js b/tests/services/ApplicationSettings.js index 234c97d9..bb7ea79f 100644 --- a/tests/services/ApplicationSettings.js +++ b/tests/services/ApplicationSettings.js @@ -1,29 +1,26 @@ -import Test from 'blue-tape'; -import { ApplicationSettings } from '../../dist/latest'; +// import { ApplicationSettings } from '../../dist/latest'; -Test('Basic init of ApplicationSettings library', async (assert)=> { - const service = new ApplicationSettings({ url: process.env.TEST_URL, token: process.env.TEST_TOKEN }); +// test('Basic init of ApplicationSettings library', async ()=> { +// const service = new ApplicationSettings({ url: process.env.TEST_URL, token: process.env.TEST_TOKEN }); - assert.true(true); -}); +// assert.true(true); +// }); -Test('Getting all the application settings', async (assert) => { - const service = new ApplicationSettings({ url: process.env.TEST_URL, token: process.env.TEST_TOKEN }); - const settings = await service.all(); +// test('Getting all the application settings', async () => { +// const service = new ApplicationSettings({ url: process.env.TEST_URL, token: process.env.TEST_TOKEN }); +// const settings = await service.all(); - // Check the settings - assert.true(true); -}); +// // Check the settings +// assert.true(true); +// }); -Test('Edit the application settings', async (assert) => { - const service = new ApplicationSettings({ url: process.env.TEST_URL, token: process.env.TEST_TOKEN }); - const settings = await service.edit({ +// test('Edit the application settings', async (assert) => { +// const service = new ApplicationSettings({ url: process.env.TEST_URL, token: process.env.TEST_TOKEN }); +// const settings = await service.edit({ - }); +// }); - // Check the settings - // Return to original state - assert.true(true); -}); - -Test.onFinish(() => process.exit(0)); +// // Check the settings +// // Return to original state +// assert.true(true); +// });