Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@lifeomic/bitrise

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lifeomic/bitrise - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

4

package.json
{
"name": "@lifeomic/bitrise",
"version": "0.3.0",
"version": "0.4.0",
"description": "Bitrise API client",

@@ -24,2 +24,3 @@ "main": "src/client.js",

"axios": "^0.18.0",
"axios-retry": "^3.1.1",
"lodash": "^4.17.10"

@@ -33,2 +34,3 @@ },

"luxon": "^1.3.1",
"nock": "^9.4.2",
"nyc": "^12.0.2",

@@ -35,0 +37,0 @@ "sinon": "^6.1.0",

const app = require('./app');
const assert = require('assert');
const axios = require('axios');
const axiosRetry = require('axios-retry');

@@ -13,2 +14,4 @@ module.exports = ({ token }) => {

axiosRetry(client, { retryDelay: axiosRetry.exponentialDelay });
const instance = {};

@@ -15,0 +18,0 @@ instance.app = ({ slug }) => app({ client, slug });

const axios = require('axios');
const client = require('..');
const nock = require('nock');
const sinon = require('sinon');

@@ -7,3 +8,12 @@ const test = require('ava');

test('an api token is required', (test) => {
test.beforeEach(() => {
nock.disableNetConnect();
});
test.afterEach(() => {
nock.enableNetConnect();
nock.cleanAll();
});
test.serial('an api token is required', (test) => {
test.throws(() => client());

@@ -15,3 +25,3 @@ test.throws(() => client({}));

test.serial('a client is authenticated', (test) => {
const create = sinon.stub(axios, 'create');
const create = sinon.spy(axios, 'create');
const token = uuid();

@@ -36,3 +46,5 @@

test.serial('a client can create an app', async (test) => {
const axiosInstance = { post: sinon.stub().rejects(new Error('fake')) };
const axiosInstance = axios.create();
sinon.stub(axiosInstance, 'post').rejects(new Error('fake'));
const create = sinon.stub(axios, 'create').returns(axiosInstance);

@@ -57,1 +69,44 @@ const slug = uuid();

});
test.serial('a client retries requests', async (test) => {
const create = sinon.spy(axios, 'create');
const token = uuid();
nock('http://localhost')
.get('/error').replyWithError('boom')
.get('/error').reply(500)
.get('/error').reply(200, 'success!');
try {
const instance = client({ token });
test.truthy(instance);
sinon.assert.calledOnce(create);
const httpClient = create.firstCall.returnValue;
const response = await httpClient.get('http://localhost/error');
test.is(response.data, 'success!');
} finally {
create.restore();
}
});
test.serial('a client gives up after too many retries', async (test) => {
const create = sinon.spy(axios, 'create');
const token = uuid();
nock('http://localhost')
.get('/error').replyWithError('boom')
.get('/error').thrice().reply(500);
try {
const instance = client({ token });
test.truthy(instance);
sinon.assert.calledOnce(create);
const httpClient = create.firstCall.returnValue;
const { response } = await test.throws(httpClient.get('http://localhost/error'));
test.is(response.status, 500);
} finally {
create.restore();
}
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc