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

bandiera-client

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bandiera-client - npm Package Compare versions

Comparing version 2.4.0 to 2.4.1

.jscsrc

6

HISTORY.md
# History
## 2.4.1 (2015-09-08)
* Update dependencies
* Run JavaScript through JSCS
* Add code coverage reporting
## 2.4.0 (2015-07-13)

@@ -5,0 +11,0 @@

23

lib/client.js

@@ -1,2 +0,1 @@

/* global afterEach, beforeEach, describe, it */
'use strict';

@@ -14,4 +13,4 @@

logger: {
debug: function () {},
warn: function () {}
debug: /* istanbul ignore next */ function() {},
warn: /* istanbul ignore next */ function() {}
},

@@ -22,7 +21,7 @@ timeout: 400

function createClient (baseUri, options) {
function createClient(baseUri, options) {
return new exports.Client(baseUri, options);
}
function BandieraClient (baseUri, options) {
function BandieraClient(baseUri, options) {
this.options = defaultOptions(options);

@@ -35,3 +34,3 @@ this.baseUri = sanitizeBaseUri(baseUri);

function sanitizeBaseUri (baseUri) {
function sanitizeBaseUri(baseUri) {
if (!baseUri) {

@@ -46,7 +45,7 @@ baseUri = 'http://localhost';

function defaultOptions (options) {
function defaultOptions(options) {
return extend(true, {}, exports.defaults, options);
}
BandieraClient.prototype.get = function (endpoint, parameters, defaultResponse, done) {
BandieraClient.prototype.get = function(endpoint, parameters, defaultResponse, done) {
var self = this;

@@ -83,3 +82,3 @@ request({

function getResponseError (response, responseBody) {
function getResponseError(response, responseBody) {
if (response.statusCode !== 200) {

@@ -97,3 +96,3 @@ return new Error('Request was unsuccessful: response status was ' + response.statusCode);

BandieraClient.prototype.getAll = function (parameters, done) {
BandieraClient.prototype.getAll = function(parameters, done) {
if (arguments.length === 1) {

@@ -106,3 +105,3 @@ done = parameters;

BandieraClient.prototype.getFeaturesForGroup = function (group, parameters, done) {
BandieraClient.prototype.getFeaturesForGroup = function(group, parameters, done) {
if (arguments.length === 2) {

@@ -115,3 +114,3 @@ done = parameters;

BandieraClient.prototype.getFeature = function (group, feature, parameters, done) {
BandieraClient.prototype.getFeature = function(group, feature, parameters, done) {
if (arguments.length === 3) {

@@ -118,0 +117,0 @@ done = parameters;

{
"name": "bandiera-client",
"version": "2.4.0",
"version": "2.4.1",

@@ -27,5 +27,7 @@ "description": "Bandiera is a simple, stand-alone feature flagging service that is not tied to any existing web framework or language. This is a client for talking to the web service.",

"node.extend": "~1.1",
"request": "~2.58"
"request": "~2.61"
},
"devDependencies": {
"istanbul": "~0.3",
"jscs": "^2",
"jshint": "^2",

@@ -32,0 +34,0 @@ "mocha": "^2",

@@ -1,3 +0,3 @@

/* global afterEach, beforeEach, describe, it */
/* jshint maxlen: false, maxstatements: false */
// jshint maxstatements: false
// jscs:disable disallowMultipleVarDecl, maximumLineLength, requireCamelCaseOrUpperCaseIdentifiers
'use strict';

@@ -10,6 +10,6 @@

describe('client', function () {
describe('client', function() {
var bandiera, extend, request;
beforeEach(function () {
beforeEach(function() {
mockery.enable({

@@ -27,30 +27,30 @@ useCleanCache: true,

afterEach(function () {
afterEach(function() {
mockery.disable();
});
it('should be an object', function () {
it('should be an object', function() {
assert.isObject(bandiera);
});
describe('.defaults', function () {
describe('.defaults', function() {
var defaults;
beforeEach(function () {
beforeEach(function() {
defaults = bandiera.defaults;
});
it('should have a `logger` property', function () {
it('should have a `logger` property', function() {
assert.isObject(defaults.logger);
});
it('should have a `logger.debug` method', function () {
it('should have a `logger.debug` method', function() {
assert.isFunction(defaults.logger.debug);
});
it('should have a `logger.warn` method', function () {
it('should have a `logger.warn` method', function() {
assert.isFunction(defaults.logger.warn);
});
it('should have a `timeout` property', function () {
it('should have a `timeout` property', function() {
assert.strictEqual(defaults.timeout, 400);

@@ -61,21 +61,21 @@ });

describe('.createClient()', function () {
describe('.createClient()', function() {
beforeEach(function () {
beforeEach(function() {
sinon.spy(bandiera, 'Client');
});
afterEach(function () {
afterEach(function() {
bandiera.Client.restore();
});
it('should be a function', function () {
it('should be a function', function() {
assert.isFunction(bandiera.createClient);
});
it('should return a `bandiera.Client` instance', function () {
it('should return a `bandiera.Client` instance', function() {
assert.isInstanceOf(bandiera.createClient('foo'), bandiera.Client);
});
it('should create a `bandiera.Client` instance with the expected arguments', function () {
it('should create a `bandiera.Client` instance with the expected arguments', function() {
var options = {};

@@ -89,9 +89,9 @@ bandiera.createClient('foo', options);

describe('.Client()', function () {
describe('.Client()', function() {
it('should be a function', function () {
it('should be a function', function() {
assert.isFunction(bandiera.Client);
});
it('should default the options', function () {
it('should default the options', function() {
var options = {};

@@ -106,10 +106,10 @@ new bandiera.Client('foo', options);

it('should return an object', function () {
it('should return an object', function() {
assert.isObject(new bandiera.Client('http://bandiera/api'));
});
describe('returned object', function () {
describe('returned object', function() {
var client, options;
beforeEach(function () {
beforeEach(function() {
options = {

@@ -124,17 +124,17 @@ logger: {

it('should have a `baseUri` property matching the baseUri it was constructed with', function () {
it('should have a `baseUri` property matching the baseUri it was constructed with', function() {
assert.strictEqual(client.baseUri, 'http://bandiera/api');
});
it('should have a `logger` property matching the passed in logger', function () {
it('should have a `logger` property matching the passed in logger', function() {
assert.deepEqual(client.logger, options.logger);
});
it('should have a `get` method', function () {
it('should have a `get` method', function() {
assert.isFunction(client.get);
});
describe('.get() when request is successful', function () {
describe('.get() when request is successful', function() {
beforeEach(function () {
beforeEach(function() {
request.yieldsAsync(null, {statusCode: 200}, {

@@ -147,4 +147,4 @@ response: {

it('should call `request` with the expected arguments', function (done) {
client.get('/v2/all', {user_group: 'foo'}, {}, function () {
it('should call `request` with the expected arguments', function(done) {
client.get('/v2/all', {user_group: 'foo'}, {}, function() {
assert.isTrue(request.calledOnce);

@@ -167,4 +167,4 @@ assert.deepEqual(request.firstCall.args[0], {

it('should callback with the expected arguments', function (done) {
client.get('/v2/all', {}, {}, function (error, response) {
it('should callback with the expected arguments', function(done) {
client.get('/v2/all', {}, {}, function(error, response) {
assert.strictEqual(error, null);

@@ -178,4 +178,4 @@ assert.deepEqual(response, {

it('should log a success message', function (done) {
client.get('/v2/all', {foo: 'bar'}, {}, function () {
it('should log a success message', function(done) {
client.get('/v2/all', {foo: 'bar'}, {}, function() {
assert.isTrue(client.logger.debug.withArgs('[BandieraClient] calling "%s" with params "%s"', '/v2/all', 'foo=bar').calledOnce);

@@ -188,6 +188,6 @@ done();

describe('.get() when request is unsuccessful', function () {
describe('.get() when request is unsuccessful', function() {
var requestError;
beforeEach(function () {
beforeEach(function() {
requestError = new Error('foo');

@@ -197,4 +197,4 @@ request.yieldsAsync(requestError, null, null);

it('should callback with the expected error', function (done) {
client.get('/v2/all', {}, {}, function (error) {
it('should callback with the expected error', function(done) {
client.get('/v2/all', {}, {}, function(error) {
assert.strictEqual(error, requestError);

@@ -205,5 +205,5 @@ done();

it('should callback the default response value', function (done) {
it('should callback the default response value', function(done) {
var defaultResponse = {defaultResponse: true};
client.get('/v2/all', {}, defaultResponse, function (error, response) {
client.get('/v2/all', {}, defaultResponse, function(error, response) {
assert.strictEqual(response, defaultResponse);

@@ -214,4 +214,4 @@ done();

it('should log a warning', function (done) {
client.get('/v2/all', {foo: 'bar'}, {}, function (error) {
it('should log a warning', function(done) {
client.get('/v2/all', {foo: 'bar'}, {}, function(error) {
assert.isTrue(client.logger.warn.withArgs('[BandieraClient] calling "%s" with params "%s": %s', '/v2/all', 'foo=bar', error.stack).calledOnce);

@@ -224,5 +224,5 @@ done();

describe('.get() when response has a non-200 status', function () {
describe('.get() when response has a non-200 status', function() {
beforeEach(function () {
beforeEach(function() {
request.yieldsAsync(null, {

@@ -233,4 +233,4 @@ statusCode: 400

it('should callback with the expected error', function (done) {
client.get('/v2/all', {statusCode: 200}, {}, function (error) {
it('should callback with the expected error', function(done) {
client.get('/v2/all', {statusCode: 200}, {}, function(error) {
assert.isNotNull(error);

@@ -242,5 +242,5 @@ assert.strictEqual(error.message, 'Request was unsuccessful: response status was 400');

it('should callback the default response value', function (done) {
it('should callback the default response value', function(done) {
var defaultResponse = {defaultResponse: true};
client.get('/v2/all', {}, defaultResponse, function (error, response) {
client.get('/v2/all', {}, defaultResponse, function(error, response) {
assert.strictEqual(response, defaultResponse);

@@ -253,10 +253,10 @@ done();

describe('.get() when response is not valid JSON', function () {
describe('.get() when response is not valid JSON', function() {
beforeEach(function () {
beforeEach(function() {
request.yieldsAsync(null, {statusCode: 200}, 'foo');
});
it('should callback with the expected error', function (done) {
client.get('/v2/all', {}, {}, function (error) {
it('should callback with the expected error', function(done) {
client.get('/v2/all', {}, {}, function(error) {
assert.isNotNull(error);

@@ -268,5 +268,5 @@ assert.strictEqual(error.message, 'API responded with invalid JSON: non-object');

it('should callback the default response value', function (done) {
it('should callback the default response value', function(done) {
var defaultResponse = {defaultResponse: true};
client.get('/v2/all', {}, defaultResponse, function (error, response) {
client.get('/v2/all', {}, defaultResponse, function(error, response) {
assert.strictEqual(response, defaultResponse);

@@ -279,10 +279,10 @@ done();

describe('.get() when response does not have the expected `response` property', function () {
describe('.get() when response does not have the expected `response` property', function() {
beforeEach(function () {
beforeEach(function() {
request.yieldsAsync(null, {statusCode: 200}, {});
});
it('should callback with the expected error', function (done) {
client.get('/v2/all', {}, {}, function (error) {
it('should callback with the expected error', function(done) {
client.get('/v2/all', {}, {}, function(error) {
assert.isNotNull(error);

@@ -294,5 +294,5 @@ assert.strictEqual(error.message, 'API responded with invalid JSON: missing response property');

it('should callback the default response value', function (done) {
it('should callback the default response value', function(done) {
var defaultResponse = {defaultResponse: true};
client.get('/v2/all', {}, defaultResponse, function (error, response) {
client.get('/v2/all', {}, defaultResponse, function(error, response) {
assert.strictEqual(response, defaultResponse);

@@ -305,10 +305,10 @@ done();

it('should have a `getAll` method', function () {
it('should have a `getAll` method', function() {
assert.isFunction(client.getAll);
});
describe('.getAll()', function () {
describe('.getAll()', function() {
var parameters, callback;
beforeEach(function () {
beforeEach(function() {
parameters = {user_group: 'foo'};

@@ -320,13 +320,13 @@ callback = sinon.spy();

afterEach(function () {
afterEach(function() {
client.get.restore();
});
it('should call `get` with the expected arguments', function () {
it('should call `get` with the expected arguments', function() {
assert.isTrue(client.get.withArgs('/v2/all', parameters, {}, callback).calledOnce);
});
describe('without parameters', function () {
describe('without parameters', function() {
beforeEach(function () {
beforeEach(function() {
client.get.restore();

@@ -338,3 +338,3 @@ callback = sinon.spy();

it('should call `get` with the expected arguments', function () {
it('should call `get` with the expected arguments', function() {
assert.isTrue(client.get.withArgs('/v2/all', {}, {}, callback).calledOnce);

@@ -347,10 +347,10 @@ });

it('should have a `getFeaturesForGroup` method', function () {
it('should have a `getFeaturesForGroup` method', function() {
assert.isFunction(client.getFeaturesForGroup);
});
describe('.getFeaturesForGroup()', function () {
describe('.getFeaturesForGroup()', function() {
var parameters, callback;
beforeEach(function () {
beforeEach(function() {
parameters = {user_group: 'foo'};

@@ -362,13 +362,13 @@ callback = sinon.spy();

afterEach(function () {
afterEach(function() {
client.get.restore();
});
it('should call `get` with the expected arguments', function () {
it('should call `get` with the expected arguments', function() {
assert.isTrue(client.get.withArgs('/v2/groups/foo/features', parameters, {}, callback).calledOnce);
});
describe('without parameters', function () {
describe('without parameters', function() {
beforeEach(function () {
beforeEach(function() {
client.get.restore();

@@ -380,3 +380,3 @@ callback = sinon.spy();

it('should call `get` with the expected arguments', function () {
it('should call `get` with the expected arguments', function() {
assert.isTrue(client.get.withArgs('/v2/groups/foo/features', {}, {}, callback).calledOnce);

@@ -389,10 +389,10 @@ });

it('should have a `getFeature` method', function () {
it('should have a `getFeature` method', function() {
assert.isFunction(client.getFeature);
});
describe('.getFeature()', function () {
describe('.getFeature()', function() {
var parameters, callback;
beforeEach(function () {
beforeEach(function() {
parameters = {user_group: 'foo'};

@@ -404,13 +404,13 @@ callback = sinon.spy();

afterEach(function () {
afterEach(function() {
client.get.restore();
});
it('should call `get` with the expected arguments', function () {
it('should call `get` with the expected arguments', function() {
assert.isTrue(client.get.withArgs('/v2/groups/foo/features/bar', parameters, false, callback).calledOnce);
});
describe('without parameters', function () {
describe('without parameters', function() {
beforeEach(function () {
beforeEach(function() {
client.get.restore();

@@ -422,3 +422,3 @@ callback = sinon.spy();

it('should call `get` with the expected arguments', function () {
it('should call `get` with the expected arguments', function() {
assert.isTrue(client.get.withArgs('/v2/groups/foo/features/bar', {}, false, callback).calledOnce);

@@ -431,3 +431,3 @@ });

it('should have an `isEnabled` method which aliases `getFeature`', function () {
it('should have an `isEnabled` method which aliases `getFeature`', function() {
assert.isFunction(client.isEnabled);

@@ -438,10 +438,10 @@ });

describe('returned object (with defaults)', function () {
describe('returned object (with defaults)', function() {
var client;
beforeEach(function () {
beforeEach(function() {
client = new bandiera.Client();
});
it('should have a `baseUri` of "http://localhost/api"', function () {
it('should have a `baseUri` of "http://localhost/api"', function() {
assert.strictEqual(client.baseUri, 'http://localhost/api');

@@ -452,10 +452,10 @@ });

describe('returned object (with no "/api" in URI)', function () {
describe('returned object (with no "/api" in URI)', function() {
var client;
beforeEach(function () {
beforeEach(function() {
client = new bandiera.Client('http://bandiera');
});
it('should have a `baseUri` property with "/api" appended', function () {
it('should have a `baseUri` property with "/api" appended', function() {
assert.strictEqual(client.baseUri, 'http://bandiera/api');

@@ -462,0 +462,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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