-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from ClemDelp/add-topics
Add topics
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
var request = require('request'); | ||
/** @namespace */ | ||
var topics = {}; | ||
|
||
module.exports = function (client) { | ||
/** | ||
* @summary List of all topics | ||
* @memberof topics | ||
* @param {done} done - Callback | ||
* | ||
* @see https://api.producthunt.com/v1/docs/topics/topics_index_list_topics | ||
*/ | ||
topics.index = function (done) { | ||
client.httpGet('/topics', {}, done); | ||
}; | ||
|
||
return topics; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
var expect = require('chai').expect; | ||
var nock = require('nock'); | ||
var sinon = require('sinon'); | ||
|
||
var Client = require('../../index'); | ||
var c = new Client(); | ||
var topics = require('../../api/v1.0.0/topics')(c); | ||
|
||
describe("topics", function() { | ||
beforeEach(function() { | ||
// Stub authenticate to be always successful | ||
sinon.stub(Client.prototype, 'authenticate', function (done) { | ||
done(null, 'test_access_token'); | ||
}); | ||
}); | ||
|
||
afterEach(function() { | ||
// Remove the stub | ||
Client.prototype.authenticate.restore(); | ||
}); | ||
|
||
describe("#index", function() { | ||
it("is successful", function(done) { | ||
nock('https://api.producthunt.com/v1') | ||
.get('/topics') | ||
.reply(200); | ||
|
||
topics.index(function (err, res) { | ||
expect(err).to.equal(null); | ||
expect(res.statusCode).to.equal(200); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |