From 142c69d6c928602c2a1766757c49c6907733a446 Mon Sep 17 00:00:00 2001 From: l12s Date: Sat, 12 Mar 2016 15:43:55 -0800 Subject: [PATCH 1/2] Updates the getData function to remove the opts key from results and adds additional tests --- lib/clients/helpers.js | 2 +- test/clients/helpers.js | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/clients/helpers.js b/lib/clients/helpers.js index f8f6a41e9..90e15babc 100644 --- a/lib/clients/helpers.js +++ b/lib/clients/helpers.js @@ -28,7 +28,7 @@ var getData = function getData(data, token) { } else { newData[key] = JSON.stringify(val); } - } else { + } else if (key !== 'opts') { newData[key] = val; } } diff --git a/test/clients/helpers.js b/test/clients/helpers.js index 80bd6ac46..7a9a591e3 100644 --- a/test/clients/helpers.js +++ b/test/clients/helpers.js @@ -64,18 +64,29 @@ describe('Client Helpers', function () { }); describe('#getAPICallArgs()', function () { - it('returns an object with the token when called with no data or cb', function () { + it('returns an args object with the token when called with no data or cb', function () { var callArgs = helpers.getAPICallArgs('test'); expect(callArgs.data).to.deep.equal({ token: 'test' }); }); - it('returns the supplied object when called with a data object and no cb', function () { - var callArgs = helpers.getAPICallArgs('test', { test: 1 }); + it('returns an args object with a token and data items when called with a data obj and no cb', + function () { + var callArgs = helpers.getAPICallArgs('test', { test: 1 }); + expect(callArgs.data).to.deep.equal({ + test: 1, + token: 'test' + }); + } + ); + + it('assigns data from the opts to the returned args obj and removes the opts key', function () { + var callArgs = helpers.getAPICallArgs('test', { test: 1, opts: { cat: 1 } }); expect(callArgs.data).to.deep.equal({ test: 1, - token: 'test' + token: 'test', + cat: 1 }); }); From b87e8d4213e5e9e765756c91904910f16b8fe19e Mon Sep 17 00:00:00 2001 From: l12s Date: Sat, 12 Mar 2016 15:45:29 -0800 Subject: [PATCH 2/2] Fixes lint issues in example-rtm-client --- examples/example-rtm-client.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/example-rtm-client.js b/examples/example-rtm-client.js index 59622ffa2..3357677a5 100644 --- a/examples/example-rtm-client.js +++ b/examples/example-rtm-client.js @@ -13,13 +13,13 @@ var rtm = new RtmClient(token, { logLevel: 'debug' }); rtm.start(); rtm.on(RTM_EVENTS.MESSAGE, function handleRtmMessage(message) { - console.log("Message:", message); + console.log('Message:', message); }); rtm.on(RTM_EVENTS.REACTION_ADDED, function handleRtmReactionAdded(reaction) { - console.log("Reaction added:", reaction); + console.log('Reaction added:', reaction); }); rtm.on(RTM_EVENTS.REACTION_REMOVED, function handleRtmReactionRemoved(reaction) { - console.log("Reaction removed:", reaction); + console.log('Reaction removed:', reaction); });