From f67ebf65b55f3d5adfb14b3f957c6da623b8c4ec Mon Sep 17 00:00:00 2001 From: Jeremy Ruppel Date: Mon, 12 Jun 2017 16:57:25 -0700 Subject: [PATCH] Set X-Flickr-API-Method header for all requests --- package.json | 2 +- request.js | 1 + test/request.js | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 21a7c5b..f459b4d 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/request.js b/request.js index 3634386..2f5c0ef 100644 --- a/request.js +++ b/request.js @@ -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); }; diff --git a/test/request.js b/test/request.js index e0a128d..c740d7a 100644 --- a/test/request.js +++ b/test/request.js @@ -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')