Skip to content
This repository has been archived by the owner on May 17, 2019. It is now read-only.

Commit

Permalink
adds more tests, switches coverage library to istanbul
Browse files Browse the repository at this point in the history
  • Loading branch information
hughrawlinson committed Mar 9, 2015
1 parent 200a0b6 commit 0b57be4
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
test:
./node_modules/.bin/jscoverage lib lib-cov
./node_modules/.bin/mocha -R mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage

clean:
rm -rf coverage lib-cov node_modules coverage.html
rm -rf coverage lib-cov coverage.html

.PHONY: test
4 changes: 4 additions & 0 deletions lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ module.exports = function search(randr) {
'mood[happy_songs][to]',
'mood[happy_songs][from'
]);

if (!params.q) {
return callback(new Error('Must specify a query'), null);
}

var query = randr.network._buildQuery(params);
var uri = 'search/tracks?' + query;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"devDependencies": {
"coveralls": "^2.11.2",
"istanbul": "^0.3.7",
"jscoverage": "^0.5.9",
"mocha": "^2.2.0",
"mocha-lcov-reporter": "0.0.2"
Expand Down
15 changes: 14 additions & 1 deletion test/Albums.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var assert = require("assert");
var app = require('../lib-cov/albums');
// setup
var RandR = require("../index");
var randr = new RandR(process.env.RANDRMUSICAPIACCESSTOKEN);
Expand Down Expand Up @@ -39,6 +38,13 @@ describe('Albums', function(){
}
);
});
it('should fail when called without a required parameter',function(done){
randr.albums.id({},function(err,data){
assert(err!=null);
done();
}
);
});
});
describe('Similar', function(){
it('should return a list of similar albums when called with a valid id', function(done){
Expand Down Expand Up @@ -73,5 +79,12 @@ describe('Albums', function(){
}
);
});
it('should fail when called without a required parameter',function(done){
randr.albums.similar({},function(err,data){
assert(err!=null);
done();
}
);
});
});
});
15 changes: 14 additions & 1 deletion test/Artists.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var assert = require("assert");
var app = require('../lib-cov/artists');
// setup
var RandR = require("../index");
var randr = new RandR(process.env.RANDRMUSICAPIACCESSTOKEN);
Expand Down Expand Up @@ -39,6 +38,13 @@ describe('Artists', function(){
}
);
});
it('should fail when called without a required parameter',function(done){
randr.artists.id({},function(err,data){
assert(err!=null);
done();
}
);
});
});
describe('Similar', function(){
it('should return a list of similar artists when called with a valid id', function(done){
Expand Down Expand Up @@ -73,5 +79,12 @@ describe('Artists', function(){
}
);
});
it('should fail when called without a required parameter',function(done){
randr.artists.similar({},function(err,data){
assert(err!=null);
done();
}
);
});
});
});
8 changes: 7 additions & 1 deletion test/Search.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var assert = require("assert");
var app = require('../lib-cov/search');
// setup
var RandR = require("../index");
var randr = new RandR(process.env.RANDRMUSICAPIACCESSTOKEN);
Expand All @@ -20,5 +19,12 @@ describe('Search', function(){
);
})
});
it('should fail when called without a required parameter',function(done){
randr.search.tracks({},function(err,data){
assert(err!=null);
done();
}
);
});
});
});
15 changes: 14 additions & 1 deletion test/Tracks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var assert = require("assert");
var app = require('../lib-cov/tracks');
// setup
var RandR = require("../index");
var randr = new RandR(process.env.RANDRMUSICAPIACCESSTOKEN);
Expand Down Expand Up @@ -39,6 +38,13 @@ describe('Tracks', function(){
}
);
});
it('should fail when called without a required parameter',function(done){
randr.tracks.id({},function(err,data){
assert(err!=null);
done();
}
);
});
});
describe('Recommendations', function(){
it('should return a list of recommendations when called with a valid id', function(done){
Expand Down Expand Up @@ -73,5 +79,12 @@ describe('Tracks', function(){
}
);
});
it('should fail when called without a required parameter',function(done){
randr.tracks.recommendations({},function(err,data){
assert(err!=null);
done();
}
);
});
});
});

0 comments on commit 0b57be4

Please sign in to comment.