Skip to content

Commit

Permalink
Fire generated function with other arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed May 18, 2019
1 parent 26a30c6 commit e400911
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions test/helpers/test_each/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ const getIndex = function(value, index) {

// If an argument is a function, its return value will be used instead.
// This can be used to generate random input for example (fuzzy testing).
const invokeArgs = function(eachArgs) {
return eachArgs.map(invokeArg)
// It will be fired with all the arguments of this iteration. This allows for
// arguments to be computed based on the value of other arguments.
const invokeArgs = function(args) {
return args.map(invokeArg)
}

const invokeArg = function(arg) {
const invokeArg = function(arg, index, args) {
if (typeof arg === 'function') {
return arg()
return arg(...args)
}

return arg
Expand Down

0 comments on commit e400911

Please sign in to comment.