Skip to content

Commit 76dbdd9

Browse files
committed
this isCallback is public & shouldn't have been
Also it makes no sense why it's dangling on the matcher like that to begin with. It's only needed in a couple places to make sure we're looking at a callback matcher before we invoke one.
1 parent 4984a26 commit 76dbdd9

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/callback.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,4 @@ export default _.tap(create({
1414
// Make callback itself quack like a matcher for its non-invoked use case.
1515
callback.__name = 'callback'
1616
callback.__matches = _.isFunction
17-
18-
callback.isCallback = obj =>
19-
obj && (obj === callback || obj.__testdouble_callback === true)
2017
})

src/matchers/is-callback.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import callback from '../callback'
2+
3+
export default function isCallback (obj) {
4+
return obj && (obj === callback || obj.__testdouble_callback === true)
5+
}

src/store/stubbings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from '../util/lodash-wrap'
22
import argsMatch from '../args-match'
3-
import callback from '../callback'
3+
import isCallback from '../matchers/is-callback'
44
import config from '../config'
55
import log from '../log'
66
import store from './index'
@@ -45,9 +45,9 @@ var executePlan = (stubbing, actualArgs, actualContext) => {
4545
}
4646

4747
var invokeCallbackFor = (stubbing, actualArgs) => {
48-
if (_.some(stubbing.args, callback.isCallback)) {
48+
if (_.some(stubbing.args, isCallback)) {
4949
_.each(stubbing.args, (expectedArg, i) => {
50-
if (callback.isCallback(expectedArg)) {
50+
if (isCallback(expectedArg)) {
5151
callCallback(stubbing, actualArgs[i], callbackArgs(stubbing, expectedArg))
5252
}
5353
})

src/when.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from './util/lodash-wrap'
22
import callback from './callback'
3+
import isCallback from './matchers/is-callback'
34
import calls from './store/calls'
45
import log from './log'
56
import stubbings from './store/stubbings'
@@ -52,7 +53,7 @@ No test double invocation call detected for \`when()\`.
5253
var concatImpliedCallback = (args, config) => {
5354
if (config.plan !== 'thenCallback') {
5455
return args
55-
} else if (!_.some(args, callback.isCallback)) {
56+
} else if (!_.some(args, isCallback)) {
5657
return args.concat(callback)
5758
} else {
5859
return args

0 commit comments

Comments
 (0)