Skip to content

Commit

Permalink
Add test coverage and linting to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ro-ka committed Sep 2, 2014
1 parent 108699a commit 558599f
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 28 deletions.
2 changes: 2 additions & 0 deletions .jshintignore
@@ -0,0 +1,2 @@
node_modules
coverage
6 changes: 3 additions & 3 deletions lib/api500px.js
Expand Up @@ -2,9 +2,9 @@
* Define the API
*/

var Photos = require("./photos").Photos,
Users = require("./users").Users,
Blogs = require("./blogs").Blogs,
var Photos = require('./photos').Photos,
Users = require('./users').Users,
Blogs = require('./blogs').Blogs,

API500px = function API500px(consumer_key) {
this._configure(consumer_key);
Expand Down
2 changes: 1 addition & 1 deletion lib/blogs.js
Expand Up @@ -2,7 +2,7 @@
* Getting blogs
*/

var Request = require("./request").Request,
var Request = require('./request').Request,
Blogs = function Blogs (consumer_key) {
this._request = new Request(consumer_key);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/photos.js
Expand Up @@ -2,7 +2,7 @@
* Getting photos
*/

var Request = require("./request").Request,
var Request = require('./request').Request,
Photos = function Photos (consumer_key) {
this._request = new Request(consumer_key);
};
Expand Down
8 changes: 5 additions & 3 deletions lib/request.js
Expand Up @@ -24,9 +24,11 @@ Request.prototype.executeRequest = function(method, parameters, callback) {
parameters.consumer_key = this.consumer_key;

for (var key in parameters) {
parameterString += (operator + key + '=' + parameters[key]);
if ( operator === '?' ) {
operator = '&';
if (key) {
parameterString += (operator + key + '=' + parameters[key]);
if ( operator === '?' ) {
operator = '&';
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion package.json
Expand Up @@ -15,9 +15,14 @@
},
"main": "./lib/api500px.js",
"scripts": {
"test": "make test"
"lint": "./node_modules/.bin/jshint .",
"pretest": "npm run-script lint",
"test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha test",
"posttest": "./node_modules/.bin/istanbul check-coverage && rm -rf coverage",
"prepublish": "npm test && npm prune"
},
"devDependencies": {
"istanbul": "^0.3.0",
"jshint": "^2.5.5",
"mocha": "^1.21.4",
"should": "^4.0.4"
Expand Down
5 changes: 3 additions & 2 deletions test/blogs-test.js
@@ -1,5 +1,6 @@
var mocha = require('mocha'),
should = require('should'),
/* global describe, it */

var should = require('should'),
config = require('./config.js'),
Blogs = require('../lib/blogs.js').Blogs;

Expand Down
10 changes: 5 additions & 5 deletions test/config.sample.js
@@ -1,9 +1,9 @@
// Enter your consumer_key below and copy file to config.js
module.exports = {
"secrets": {
"consumer_key": "YOUR_SECRET_CUSTOMER_KEY",
"user_id": "YOUR_USER_ID",
"user_name": "YOUR_USER_NAME",
"user_email": "YOUR_EMAIL"
'secrets': {
'consumer_key': 'YOUR_SECRET_CUSTOMER_KEY',
'user_id': 'YOUR_USER_ID',
'user_name': 'YOUR_USER_NAME',
'user_email': 'YOUR_EMAIL'
}
};
25 changes: 15 additions & 10 deletions test/photos-test.js
@@ -1,5 +1,6 @@
var mocha = require('mocha'),
should = require('should'),
/* global describe, it */

var should = require('should'),
config = require('./config.js'),
Photos = require('../lib/photos.js').Photos;

Expand Down Expand Up @@ -48,14 +49,18 @@ describe('Testing GET photos:', function() {

describe('#getFavoritesByUsername()', function() {
it('should return a json with photos', function(done) {
photos.getFavoritesByUsername(user_name, {'rpp': 7}, function(err, result) {
should.not.exist(err);
should.exist(result);
result.should.have.property('photos');
result.photos.should.have.lengthOf(7);

done();
});
photos.getFavoritesByUsername(
user_name,
{ 'rpp': 7 },
function(err, result) {
should.not.exist(err);
should.exist(result);
result.should.have.property('photos');
result.photos.should.have.lengthOf(7);

done();
}
);
});
});

Expand Down
5 changes: 3 additions & 2 deletions test/users-test.js
@@ -1,5 +1,6 @@
var mocha = require('mocha'),
should = require('should'),
/* global describe, it */

var should = require('should'),
config = require('./config.js'),
Users = require('../lib/users.js').Users;

Expand Down

0 comments on commit 558599f

Please sign in to comment.