Skip to content

Commit

Permalink
Merge pull request #174 from slackhq/update_getData
Browse files Browse the repository at this point in the history
Updates the getData function to remove the opts key from results and …
  • Loading branch information
Leah Jones committed Mar 12, 2016
2 parents 5e8b158 + b87e8d4 commit e95416a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 3 additions & 3 deletions examples/example-rtm-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
2 changes: 1 addition & 1 deletion lib/clients/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var getData = function getData(data, token) {
} else {
newData[key] = JSON.stringify(val);
}
} else {
} else if (key !== 'opts') {
newData[key] = val;
}
}
Expand Down
19 changes: 15 additions & 4 deletions test/clients/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
});

Expand Down

0 comments on commit e95416a

Please sign in to comment.