Skip to content

Commit

Permalink
Refactor applyArguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark1626 committed Dec 18, 2019
1 parent 255138b commit d0981c8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/jest-each/src/bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const bindConcurrent = (
return tests.forEach(row =>
cb(
row.title,
applyArgumentsConcurrent(supportsDone, row.arguments, test),
applyArguments(supportsDone, row.arguments, test),
timeout,
),
);
Expand Down Expand Up @@ -107,21 +107,21 @@ const buildTemplateTests = (
const getHeadingKeys = (headings: string): Array<string> =>
headings.replace(/\s/g, '').split('|');

function applyArguments(
supportsDone: boolean,
params: Array<unknown>,
test: Global.ConcurrentEachTestFn,
): Global.ConcurrentEachTestFn;
function applyArguments(
supportsDone: boolean,
params: Array<unknown>,
test: Global.EachTestFn,
): Global.EachTestFn {
return supportsDone && params.length < test.length
? (done: Global.DoneFn) => test(...params, done)
: () => test(...params);
}

function applyArgumentsConcurrent(
): Global.EachTestFn;
function applyArguments(
supportsDone: boolean,
params: Array<unknown>,
test: Global.ConcurrentEachTestFn,
): Global.ConcurrentEachTestFn {
test: Global.ConcurrentEachTestFn | Global.EachTestFn,
): Global.ConcurrentEachTestFn | Global.EachTestFn {
return supportsDone && params.length < test.length
? (done: Global.DoneFn) => test(...params, done)
: () => test(...params);
Expand Down

0 comments on commit d0981c8

Please sign in to comment.