hacker-news-api
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -137,6 +137,6 @@ 'use strict'; | ||
searchPosts: function (query, cb) { | ||
hn.call('search?query=' + query + '&tags=story', cb); | ||
hn.call('search', {query: query, tags: 'story'}, cb); | ||
}, | ||
searchLastPosts: function (query, cb) { | ||
hn.call('search_by_date?query=' + query + '&tags=story', cb); | ||
hn.call('search_by_date', {query: query, tags: 'story'}, cb); | ||
}, | ||
@@ -143,0 +143,0 @@ |
{ | ||
"name": "hacker-news-api", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Node.js library for Algolia's Hacker News API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -15,2 +15,20 @@ var https = require('https'); | ||
'/api/v1/search_by_date?tags=story', | ||
'/api/v1/items/17', | ||
'/api/v1/users/pg', | ||
'/api/v1/search?tags=comment%2Cauthor_pg', | ||
'/api/v1/search_by_date?tags=comment%2Cauthor_pg', | ||
'/api/v1/search?tags=poll%2Cauthor_pg', | ||
'/api/v1/search_by_date?tags=poll%2Cauthor_pg', | ||
'/api/v1/search?tags=story%2Cauthor_pg', | ||
'/api/v1/search_by_date?tags=story%2Cauthor_pg', | ||
'/api/v1/search?query=apple&tags=comment', | ||
'/api/v1/search_by_date?query=apple&tags=comment', | ||
'/api/v1/search?query=apple&tags=poll', | ||
'/api/v1/search_by_date?query=apple&tags=poll', | ||
'/api/v1/search?query=apple&tags=story', | ||
'/api/v1/search_by_date?query=apple&tags=story', | ||
'/api/v1/search?query=apple&tags=story', | ||
'/api/v1/search_by_date?query=apple&tags=story', | ||
'/api/v1/search?tags=ask_hn&query=apple&page=2', | ||
'/api/v1/search_by_date?tags=ask_hn&query=apple&page=2', | ||
]; | ||
@@ -17,0 +35,0 @@ |
@@ -10,3 +10,2 @@ var hn = require("./../index.js"); | ||
fixtures.forEach(function(f) { | ||
console.log(f.url); | ||
api.get(f.url).reply(200, f.reply); | ||
@@ -37,3 +36,3 @@ }); | ||
expect(data).to.have.property('hits'); | ||
data.hits.map(function(comment) { | ||
data.hits.forEach(function(comment) { | ||
var intersection = tags.filter(function(n) { | ||
@@ -47,2 +46,15 @@ return comment._tags.indexOf(n) != -1; | ||
function verifyDataHasAllOfTags(err, data, tags, done) { | ||
if(err) { | ||
return done("Error"); | ||
} | ||
expect(data).to.have.property('hits'); | ||
data.hits.forEach(function(item) { | ||
tags.forEach(function(tag) { | ||
expect(item._tags).to.contain(tag); | ||
}); | ||
}); | ||
done(); | ||
} | ||
it('should get comments', function(done) { | ||
@@ -78,2 +90,77 @@ hn.getComments(crazy_curry(['comment'], done, verifyDataHasOneOfTags)); | ||
}); | ||
it('should get item', function(done) { | ||
hn.getItem(17, function(err, res) { | ||
if(err) return done(err); | ||
expect(res.id).to.equal(17); | ||
expect(res.type).to.equal('comment'); | ||
done(); | ||
}); | ||
}); | ||
it('should get user', function(done) { | ||
hn.getUser('pg', function(err, res) { | ||
if(err) return done(err); | ||
expect(res.username).to.equal('pg'); | ||
done(); | ||
}); | ||
}); | ||
it('should get user comments', function(done) { | ||
hn.getUserComments('pg', crazy_curry(['comment','author_pg'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should get last user comments', function(done) { | ||
hn.getLastUserComments('pg', crazy_curry(['comment','author_pg'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should get user polls', function(done) { | ||
hn.getUserPolls('pg', crazy_curry(['poll','author_pg'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should get last user polls', function(done) { | ||
hn.getLastUserPolls('pg', crazy_curry(['poll','author_pg'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should get user stories', function(done) { | ||
hn.getUserStories('pg', crazy_curry(['story','author_pg'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should get last user stories', function(done) { | ||
hn.getLastUserStories('pg', crazy_curry(['story','author_pg'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search comments', function(done) { | ||
hn.searchComments('apple', crazy_curry(['comment'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search last comments', function(done) { | ||
hn.searchLastComments('apple', crazy_curry(['comment'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search polls', function(done) { | ||
hn.searchPolls('apple', crazy_curry(['poll'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search last polls', function(done) { | ||
hn.searchLastPolls('apple', crazy_curry(['poll'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search posts', function(done) { | ||
hn.searchPosts('apple', crazy_curry(['story'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search last posts', function(done) { | ||
hn.searchLastPosts('apple', crazy_curry(['story'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search posts', function(done) { | ||
hn.searchStories('apple', crazy_curry(['story'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search last posts', function(done) { | ||
hn.searchLastStories('apple', crazy_curry(['story'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search', function(done) { | ||
hn.search({tags: 'ask_hn', query: 'apple', page: 2}, crazy_curry(['ask_hn'], done, verifyDataHasAllOfTags)); | ||
}); | ||
it('should search last', function(done) { | ||
hn.searchLast({tags: 'ask_hn', query: 'apple', page: 2}, crazy_curry(['ask_hn'], done, verifyDataHasAllOfTags)); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
758742
317
1