Skip to content

Commit

Permalink
Merge pull request #64 from jeremyruppel/headers
Browse files Browse the repository at this point in the history
Set X-Flickr-API-Method header for all requests
  • Loading branch information
jeremyruppel authored Jun 13, 2017
2 parents 8717664 + f67ebf6 commit 07ab4ff
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flickr-sdk",
"version": "3.0.0-alpha.3",
"version": "3.0.0-alpha.4",
"description": "Almost certainly the best Flickr API client in the world for node and the browser",
"keywords": [
"flickr",
Expand Down
1 change: 1 addition & 0 deletions request.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = function createClient(auth) {
return request(verb, 'https://api.flickr.com/services/rest')
.query('method=' + method)
.query(args)
.set('X-Flickr-API-Method', method)
.use(json)
.use(auth);
};
Expand Down
21 changes: 21 additions & 0 deletions test/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ var nock = require('nock');

describe('request', function () {

it('adds default request headers', function () {
var api = nock('https://api.flickr.com', {
reqheaders: {
'X-Flickr-API-Method': 'flickr.test.echo'
}
})
.get('/services/rest')
.query({
method: 'flickr.test.echo',
format: 'json',
nojsoncallback: 1
})
.reply(200, {stat: 'ok'});

return subject('GET', 'flickr.test.echo').then(function (res) {
assert(api.isDone(), 'Expected mock to have been called');
assert.equal(res.statusCode, 200);
assert.equal(res.body.stat, 'ok');
});
});

it('adds default query string arguments', function () {
var api = nock('https://api.flickr.com')
.get('/services/rest')
Expand Down

0 comments on commit 07ab4ff

Please sign in to comment.