Skip to content

Commit 5eb17fd

Browse files
committed
Now erroring if undifnied is passed to td.object
1 parent 212a023 commit 5eb17fd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/object.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ var fakeObject = (nameOrType, config) => {
1515
return createTestDoublesForFunctionNames(nameOrType)
1616
} else if (_.isObjectLike(nameOrType)) {
1717
return imitate(nameOrType)
18-
} else if (_.isString(nameOrType) || nameOrType === undefined) {
18+
} else if (_.isString(nameOrType) || arguments.length === 0) {
1919
return createTestDoubleViaProxy(nameOrType, withDefaults(config))
20+
} else if (nameOrType === undefined) {
21+
2022
} else if (_.isFunction(nameOrType)) {
2123
ensureFunctionIsNotPassed()
2224
} else {
@@ -56,6 +58,9 @@ Did you mean \`td.object(['${name}'])\`?\
5658
}
5759
}
5860

61+
var ensureUndifinedVariableNotPassed = () =>
62+
log.error('td.object', `undefined variable was passed to \`td.object\` (as of [email protected]). Please use \`td.object()\` or \`td.object('someString')\` to create a test doulbe via proxy.`)
63+
5964
var ensureFunctionIsNotPassed = () =>
6065
log.error('td.object', `Functions are not valid arguments to \`td.object\` (as of [email protected]). Please use \`td.function()\` or \`td.constructor()\` instead for creating fake functions.`)
6166

0 commit comments

Comments
 (0)