Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates the getData function to remove the opts key from results and … #174

Merged
2 commits merged into from
Mar 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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