Skip to content

Commit

Permalink
Add 'explore' endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Wood committed Oct 23, 2017
1 parent e7035ea commit b393a05
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
15 changes: 15 additions & 0 deletions lib/explore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@
*/
module.exports = api => {
return {
/**
* Retrieve a list of explore streams.
*
* @see https://pnut.io/docs/api/resources/explore#get-posts-streams-explore
* @example
* const { meta, data } = await pnut.explore();
* @param {Object} [params] - Additional URI parameters
* @returns {Promise}
*/
explore(params = {}) {
return api.request("/posts/streams/explore", {
params: params
});
},

/**
* New conversations just starting on pnut.io
*
Expand Down
23 changes: 19 additions & 4 deletions test/explore_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,28 @@ const pnut = require("../lib/pnut");
before(function() {
let base = "https://api.pnut.io/v0";

nock(base).get("/posts/streams/explore/conversations").reply(200, {});
nock(base).get("/posts/streams/explore/photos").reply(200, {});
nock(base).get("/posts/streams/explore/trending").reply(200, {});
nock(base).get("/posts/streams/explore/missed_conversations").reply(200, {});
nock(base)
.get("/posts/streams/explore")
.reply(200, {});
nock(base)
.get("/posts/streams/explore/conversations")
.reply(200, {});
nock(base)
.get("/posts/streams/explore/photos")
.reply(200, {});
nock(base)
.get("/posts/streams/explore/trending")
.reply(200, {});
nock(base)
.get("/posts/streams/explore/missed_conversations")
.reply(200, {});
});

describe("Explore", () => {
it("should be able to fetch the explore endpoint", () => {
return pnut.explore().should.become({});
});

it("should be able to fetch the 'explore conversations' stream", () => {
return pnut.conversations().should.become({});
});
Expand Down

0 comments on commit b393a05

Please sign in to comment.