From 7ff5270679d013f472c2e8303fab68f4f4e6a643 Mon Sep 17 00:00:00 2001 From: Laurent RENARD Date: Sun, 11 Apr 2021 15:27:59 +0200 Subject: [PATCH] add collection fonction to the delegate --- src/assertion.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/assertion.ts b/src/assertion.ts index b6275b2..cd4a48b 100644 --- a/src/assertion.ts +++ b/src/assertion.ts @@ -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)]) ); @@ -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); + } }; };