Socket
Socket
Sign inDemoInstall

citibike

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.3 to 2.1.4

test/api.test.js

24

History.md

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

2.1.3 / 2013-06-22
==================
* Minor Formatting
* Added documentation for sample JSON responses
2.1.2 / 2013-06-20
==================
* Fixed tests (capitalization error)
2.1.1 / 2013-06-20
==================
* Minor formatting
* Added Travis CI support for Node v0.9
* Added documentation
2.1.0 / 2013-06-19
==================
* Revised Example
* Revised Tests
* Added Travis CI implementation
2.0.1 / 2013-06-19

@@ -3,0 +27,0 @@ ==================

27

lib/citibike.js

@@ -26,3 +26,3 @@ "use strict";

this.defaults = {
api_key: null,
apiKey: null,

@@ -35,7 +35,7 @@ headers: {

rest_base: 'http://appservices.citibikenyc.com/',
helmet_url: 'v1/helmet/list',
branch_url: 'v1/branch/list',
stations_url: 'data2/stations.php',
stations_stream_url: 'data2/stations.php?updateOnly=true', // TODO : make param not separate url
restBase: 'http://appservices.citibikenyc.com',
helmetsURL: '/v1/helmet/list',
branchesURL: '/v1/branch/list',
stationsURL: '/data2/stations.php',
stationsStreamURL: '/data2/stations.php?updateOnly=true', // TODO : make param not separate url

@@ -61,8 +61,11 @@ };

if ( typeof callback !== 'function' ) {
throw "ERROR: Invalid callback function.";
return this;
throw new Error('ERROR: Invalid callback function.');
}
if (url == null) {
throw new Error('ERROR: Invalid URL called.');
}
if (url.charAt(0) == '/')
url = this.options.rest_base + url;
url = this.options.restBase + url;

@@ -95,3 +98,3 @@ // Holds data from HTTP response body

Citibike.prototype.getStations = function( params, callback ) {
var url = this.options.rest_base + this.options.stations_url;
var url = this.options.restBase + this.options.stationsURL;
this.get(url, params, function(data) {

@@ -110,3 +113,3 @@ callback(data);

Citibike.prototype.getBranches = function( params, callback ) {
var url = this.options.rest_base + this.options.branch_url;
var url = this.options.restBase + this.options.branchesURL;
this.get(url, params, function(data) {

@@ -125,3 +128,3 @@ callback(data);

Citibike.prototype.getHelmets = function( params, callback ) {
var url = this.options.rest_base + this.options.helmet_url;
var url = this.options.restBase + this.options.helmetsURL;
this.get(url, params, function(data) {

@@ -128,0 +131,0 @@ callback(data);

@@ -10,5 +10,8 @@ {

"nyc",
"api"
"api",
"citibike",
"rest",
"transportation"
],
"version": "2.1.3",
"version": "2.1.4",
"author": "Kevin Coughlin <kevintcoughlin@gmail.com>",

@@ -29,3 +32,5 @@ "contributors": [

"devDependencies": {
"mocha": "*"
"supertest": "*",
"mocha": ">= 1.11.0",
"should": ">= 1.2.2"
},

@@ -32,0 +37,0 @@ "directories": {

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

# Citibike [![Build Status](https://travis-ci.org/KevinTCoughlin/citibike.png)](https://travis-ci.org/KevinTCoughlin/citibike)
# Citibike [![Build Status](https://travis-ci.org/KevinTCoughlin/citibike.png)](https://travis-ci.org/KevinTCoughlin/citibike) [![Dependency Status](https://gemnasium.com/KevinTCoughlin/citibike.png)](https://gemnasium.com/KevinTCoughlin/citibike)

@@ -27,3 +27,3 @@ A [node.js](http://nodejs.org/) wrapper for [Citibike](http://citibikenyc.com/)'s REST API.

* [node](http://nodejs.org/) v0.6 +
* [Node.js](http://nodejs.org/) v0.8 +

@@ -157,1 +157,3 @@ ## Notes

WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/KevinTCoughlin/citibike/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

@@ -1,25 +0,38 @@

/*
"use strict";
/**
* Tests for HTTP GET requests
* Test Framework: Mocha (http://visionmedia.github.io/mocha/)
* Assertions: Should (https://github.com/visionmedia/should.js/)
*/
var Citibike = require('..')
, assert = require('assert');
var Citibike = require('..'),
should = require('should');
beforeEach(function(done){
var citibike = new Citibike();
})
var citibike;
beforeEach(function(){
citibike = new Citibike;
});
describe('Citibike.get()', function() {
specify('HTTP GET request', function (done) {
it('should throw error if callback is not typeof function', function () {
assert.throws(
function () {
citibike.get(null, null, 'string');
}
);
});
it('should throw error if callback is not typeof function', function () {
(function() {
citibike.get(null, null, 'string');
}).should.throwError('ERROR: Invalid callback function.');
});
it('should successfully complete request', function (done) {
citibike.get(null, null, function(data) {
done();
it('should throw error if an invalid url is passed', function () {
(function() {
citibike.get(null, null, function(done) {
});
}).should.throwError('ERROR: Invalid URL called.');
});
it('should successfully complete a request', function (done) {
var url = citibike.defaults.restBase + citibike.defaults.helmetsURL;
citibike.get(url, null, function(data) {
should.exist(data);
should.exist(data.results);
data.results.should.not.be.empty;
done();
});

@@ -30,30 +43,29 @@ });

describe('Citibike.getStations()', function () {
specify('HTTP GET request', function (done) {
it('should successfully complete request', function (done) {
citibike.getStations(null, function(data) {
should.exist(data);
data.results.should.not.be.empty;
done();
});
});
});
});
describe('Citibike.getBranches()', function () {
specify('HTTP GET request', function (done) {
it('should successfully complete request', function (done) {
citibike.getBranches(null, function(data) {
should.exist(data);
data.results.should.not.be.empty;
done();
});
});
});
});
describe('Citibike.getHelmets()', function () {
specify('HTTP GET request', function (done) {
it('should successfully complete request', function (done) {
citibike.getHelmets(null, function(data) {
should.exist(data);
data.results.should.not.be.empty;
done();
});
});
});
});
*/
});

@@ -1,8 +0,11 @@

"use strict";
/**
* Tests for HTTP GET requests
* Test Framework: Mocha (http://visionmedia.github.io/mocha/)
* Assertions: Should (https://github.com/visionmedia/should.js/)
*/
var Citibike = require('..')
, utils = require('../lib/utils')
, assert = require('assert');
var Citibike = require('..');
var utils = require('../lib/utils');
var should = require ('should');
/** Tests for Citibike Client Creation */
describe('Create citibike client', function () {

@@ -13,3 +16,3 @@ describe('Correct Defaults', function () {

var defaults = {
api_key: null,
apiKey: null,

@@ -22,20 +25,20 @@ headers: {

rest_base: 'http://appservices.citibikenyc.com/',
helmet_url: 'v1/helmet/list',
branch_url: 'v1/branch/list',
stations_url: 'data2/stations.php',
stations_stream_url: 'data2/stations.php?updateOnly=true',
restBase: 'http://appservices.citibikenyc.com',
helmetsURL: '/v1/helmet/list',
branchesURL: '/v1/branch/list',
stationsURL: '/data2/stations.php',
stationsStreamURL: '/data2/stations.php?updateOnly=true'
};
var citibike = new Citibike;
assert.deepEqual(citibike.defaults, defaults);
var citibike = new Citibike();
citibike.defaults.should.eql(defaults);
});
it('should have correct API endpoints as defaults', function () {
var citibike = new Citibike;
assert.equal(citibike.defaults.rest_base, 'http://appservices.citibikenyc.com/');
assert.equal(citibike.defaults.helmet_url, 'v1/helmet/list');
assert.equal(citibike.defaults.branch_url, 'v1/branch/list');
assert.equal(citibike.defaults.stations_url, 'data2/stations.php');
assert.equal(citibike.defaults.stations_stream_url, 'data2/stations.php?updateOnly=true');
var citibike = new Citibike();
citibike.defaults.restBase.should.equal('http://appservices.citibikenyc.com');
citibike.defaults.helmetsURL.should.equal('/v1/helmet/list');
citibike.defaults.branchesURL.should.equal('/v1/branch/list');
citibike.defaults.stationsURL.should.equal('/data2/stations.php');
citibike.defaults.stationsStreamURL.should.equal('/data2/stations.php?updateOnly=true');
});

@@ -46,3 +49,3 @@

var defaults = {
api_key: null,
apiKey: null,

@@ -55,17 +58,17 @@ headers: {

rest_base: 'http://appservices.citibikenyc.com/',
helmet_url: 'v1/helmet/list',
branch_url: 'v1/branch/list',
stations_url: 'data2/stations.php',
stations_stream_url: 'data2/stations.php?updateOnly=true',
restBase: 'http://appservices.citibikenyc.com',
helmetsURL: '/v1/helmet/list',
branchesURL: '/v1/branch/list',
stationsURL: '/data2/stations.php',
stationsStreamURL: '/data2/stations.php?updateOnly=true'
},
options = {
api_key: 'users_key'
};
options = {
apiKey: 'users_key'
};
var citibike = new Citibike(options);
assert.deepEqual(citibike.options, utils.merge(defaults, options));
var citibike = new Citibike(options);
citibike.options.should.eql(utils.merge(defaults, options));
});
});
});

@@ -1,28 +0,34 @@

"use strict";
/**
* Tests for HTTP GET requests
* Test Framework: Mocha (http://visionmedia.github.io/mocha/)
* Assertions: Should (https://github.com/visionmedia/should.js/)
*/
var Citibike = require('..'),
utils = require('../lib/utils'),
should = require('should');
var Citibike = require('..')
, utils = require('../lib/utils')
, assert = require('assert');
/** Tests for Citibike Utility Functions */
describe('Citibike.utils', function () {
describe('.merge()', function () {
it('should return an object with the second object\'s values merged with the first.');
var options = {
"key1": "value1",
"key2": "value2"
},
defaults = {
"key1": "default1",
"key2": "default2",
"key3": "default3"
},
result = {
"key1": "value1",
"key2": "value2",
"key3": "default3"
};
assert.deepEqual(result, utils.merge(defaults, options));
it('should return an object with the second object\'s values merged with the first.', function() {
var options = {
"key1": "value1",
"key2": "value2"
},
defaults = {
"key1": "default1",
"key2": "default2",
"key3": "default3"
},
result = {
"key1": "value1",
"key2": "value2",
"key3": "default3"
};
result.should.eql(utils.merge(defaults, options));
});
});
});

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc