Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Better check for .makeArguments id #15

Merged
merged 2 commits into from
Dec 28, 2014
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports.hookObject = function(method, args) {

exports.makeArguments = function(hookObject) {
var result = [];
if(hookObject.id) {
if(typeof hookObject.id !== 'undefined') {
result.push(hookObject.id);
}

Expand Down
10 changes: 10 additions & 0 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ describe('hook utilities', function() {

assert.deepEqual(args, [2, { my: 'data' }, { some: 'thing' }, _.noop]);

args = utils.makeArguments({
id: 0,
data: { my: 'data' },
params: { some: 'thing' },
method: 'update',
callback: _.noop
});

assert.deepEqual(args, [0, { my: 'data' }, { some: 'thing' }, _.noop]);

args = utils.makeArguments({
params: { some: 'thing' },
method: 'find',
Expand Down