Skip to content

Commit

Permalink
patch(vest): cleaner omit
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Mar 22, 2022
1 parent 6c0d43c commit 4eaea36
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/vest/src/core/test/omitOptionalTests.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import hasOwnProperty from 'hasOwnProperty';
import { isEmpty } from 'isEmpty';
import isFunction from 'isFunction';
import * as nestedArray from 'nestedArray';
Expand All @@ -18,15 +19,10 @@ export default function omitOptionalTests(): void {
nestedArray.transform(tests, (testObject: VestTest) => {
const fieldName = testObject.fieldName;

if (shouldOmit.hasOwnProperty(fieldName)) {
if (hasOwnProperty(shouldOmit, fieldName)) {
omit(testObject);
} else {
const optionalConfig = optionalFields[fieldName];
if (isFunction(optionalConfig)) {
shouldOmit[fieldName] = optionalConfig();

omit(testObject);
}
runOptionalConfig(testObject);
}

return testObject;
Expand All @@ -38,4 +34,13 @@ export default function omitOptionalTests(): void {
testObject.omit();
}
}

function runOptionalConfig(testObject: VestTest) {
const optionalConfig = optionalFields[testObject.fieldName];
if (isFunction(optionalConfig)) {
shouldOmit[testObject.fieldName] = optionalConfig();

omit(testObject);
}
}
}

1 comment on commit 4eaea36

@vercel
Copy link

@vercel vercel bot commented on 4eaea36 Mar 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest-next – ./website

vest-website.vercel.app
vest-next-ealush.vercel.app
vest-next.vercel.app
vest-next-git-latest-ealush.vercel.app

Please sign in to comment.