Skip to content

Commit e95416a

Browse files
author
Leah Jones
committed
Merge pull request #174 from slackhq/update_getData
Updates the getData function to remove the opts key from results and …
2 parents 5e8b158 + b87e8d4 commit e95416a

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

examples/example-rtm-client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ var rtm = new RtmClient(token, { logLevel: 'debug' });
1313
rtm.start();
1414

1515
rtm.on(RTM_EVENTS.MESSAGE, function handleRtmMessage(message) {
16-
console.log("Message:", message);
16+
console.log('Message:', message);
1717
});
1818

1919
rtm.on(RTM_EVENTS.REACTION_ADDED, function handleRtmReactionAdded(reaction) {
20-
console.log("Reaction added:", reaction);
20+
console.log('Reaction added:', reaction);
2121
});
2222

2323
rtm.on(RTM_EVENTS.REACTION_REMOVED, function handleRtmReactionRemoved(reaction) {
24-
console.log("Reaction removed:", reaction);
24+
console.log('Reaction removed:', reaction);
2525
});

lib/clients/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ var getData = function getData(data, token) {
2828
} else {
2929
newData[key] = JSON.stringify(val);
3030
}
31-
} else {
31+
} else if (key !== 'opts') {
3232
newData[key] = val;
3333
}
3434
}

test/clients/helpers.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,29 @@ describe('Client Helpers', function () {
6464
});
6565

6666
describe('#getAPICallArgs()', function () {
67-
it('returns an object with the token when called with no data or cb', function () {
67+
it('returns an args object with the token when called with no data or cb', function () {
6868
var callArgs = helpers.getAPICallArgs('test');
6969
expect(callArgs.data).to.deep.equal({
7070
token: 'test'
7171
});
7272
});
7373

74-
it('returns the supplied object when called with a data object and no cb', function () {
75-
var callArgs = helpers.getAPICallArgs('test', { test: 1 });
74+
it('returns an args object with a token and data items when called with a data obj and no cb',
75+
function () {
76+
var callArgs = helpers.getAPICallArgs('test', { test: 1 });
77+
expect(callArgs.data).to.deep.equal({
78+
test: 1,
79+
token: 'test'
80+
});
81+
}
82+
);
83+
84+
it('assigns data from the opts to the returned args obj and removes the opts key', function () {
85+
var callArgs = helpers.getAPICallArgs('test', { test: 1, opts: { cat: 1 } });
7686
expect(callArgs.data).to.deep.equal({
7787
test: 1,
78-
token: 'test'
88+
token: 'test',
89+
cat: 1
7990
});
8091
});
8192

0 commit comments

Comments
 (0)