Skip to content

Commit

Permalink
add collection fonction to the delegate
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzofox3 committed Apr 11, 2021
1 parent d4ba845 commit 7ff5270
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/assertion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ const aliasMethodHook = (methodName: string) => function (...args) {
};

const unbindAssert = (target: Assert): { [p: string]: (...args) => any } => Object.fromEntries(
Object
.keys(AssertPrototype)
[...Object.keys(AssertPrototype), 'collect']
.map((methodName) => [methodName, (...args) => target[methodName](...args)])
);

Expand Down Expand Up @@ -172,19 +171,19 @@ export const assert = (collect, offset: number, runOnly = false): Assert => {
return {
...unbindAssert(Object.create(AssertPrototype, {collect: {value: actualCollect}})),
test(description, spec, opts = {}) {
if (runOnly) {
return skip(description, spec, opts);
}
return test(description, spec, opts);
},
if (runOnly) {
return skip(description, spec, opts);
}
return test(description, spec, opts);
},
skip(description: string, spec = noop, opts = {}) {
return skip(description, spec, opts);
},
return skip(description, spec, opts);
},
only(description: string, spec, opts = {}) {
const specFn = runOnly === false ? _ => {
throw new Error(`Can not use "only" method when not in run only mode`);
} : spec;
return test(description, specFn, opts);
}
const specFn = runOnly === false ? _ => {
throw new Error(`Can not use "only" method when not in run only mode`);
} : spec;
return test(description, specFn, opts);
}
};
};

0 comments on commit 7ff5270

Please sign in to comment.