Skip to content

Commit

Permalink
chore: cleanup residue
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 10, 2021
1 parent 4032bd8 commit 40ef071
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 27 deletions.
5 changes: 2 additions & 3 deletions packages/n4s/src/modifiers/partial.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import enforce from 'enforce';
import type { TShapeObject } from 'genEnforceLazy';
import type { TShapeObject, TLazy } from 'genEnforceLazy';

export default function partial(shapeObject: TShapeObject): TShapeObject {
const output: TShapeObject = {};
for (const key in shapeObject) {
// @ts-expect-error - This is pretty tricky to get right. Everything works, but ts still doesn't like it
output[key] = enforce.optional(shapeObject[key]);
output[key] = enforce.optional(shapeObject[key]) as TLazy;
}

return output;
Expand Down
7 changes: 2 additions & 5 deletions packages/n4s/src/runtime/enforce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,9 @@ const enforce = genEnforce();

export default enforce;

export type TEnforce = TModifiers &
TEnforceEager &
TLazyRules &
TEnforceMethods;
type TEnforce = TEnforceEager & TLazyRules & TEnforceMethods;

type TEnforceMethods = {
type TEnforceMethods = TModifiers & {
context: () => TEnforceContext;
extend: (customRules: TRule) => void;
};
2 changes: 1 addition & 1 deletion packages/n4s/src/runtime/runtimeRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type TRuleBase = (value: TRuleValue, ...args: TArgs) => TRuleReturn;

export type TRule = Record<string, TRuleBase>;

export type TBaseRules = typeof baseRules;
type TBaseRules = typeof baseRules;
export type KBaseRules = keyof TBaseRules;

const baseRules = Object.assign(rules(), compounds(), schema());
Expand Down
1 change: 0 additions & 1 deletion packages/vest/src/core/state/createStateRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export default function createStateRef(
{ suiteId }: { suiteId: string }
) {
return {
carryOverTests: state.registerStateKey<VestTest[]>(() => []),
lagging: state.registerStateKey<VestTest[]>(() => []),
optionalFields: state.registerStateKey<Record<string, boolean>>(() => ({})),
pending: state.registerStateKey<VestTest[]>(() => []),
Expand Down
11 changes: 4 additions & 7 deletions packages/vest/src/core/state/stateHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import type { TStateRef } from 'createStateRef';
import ctx from 'ctx';
import type { TDraftResult } from 'produceDraft';

export function useCarryOverTests(): TStateHandlerReturn<VestTest[]> {
return useStateRef().carryOverTests();
}
export function usePending(): TStateHandlerReturn<VestTest[]> {
return useStateRef().pending();
}
Expand Down Expand Up @@ -40,10 +37,6 @@ export function useTestsOrdered(): TStateHandlerReturn<VestTest[]> {
return useStateRef().testsOrdered();
}

export function useCursorAt(): TStateHandlerReturn<number> {
return useStateRef().testsOrderedCursor();
}

export function useTestAtCursor(initialValue: VestTest): VestTest {
const [cursorAt] = useCursorAt();
const [testsOrder, setTestsOrder] = useTestsOrdered();
Expand Down Expand Up @@ -85,3 +78,7 @@ export function useRefreshTestObjects(): void {

setTestsOrder(testsOrdered => testsOrdered.slice(0));
}

function useCursorAt(): TStateHandlerReturn<number> {
return useStateRef().testsOrderedCursor();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
exports[`suite.subscribe Should call handler on suite subscription initialization 1`] = `
Object {
"suiteState": Object {
"carryOverTests": [Function],
"lagging": [Function],
"optionalFields": [Function],
"pending": [Function],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

exports[`runAsyncTest: failing State updates Initial state matches snapshot (sanity) 1`] = `
Object {
"carryOverTests": Array [],
"lagging": Array [],
"optionalFields": Object {},
"pending": Array [
Expand Down Expand Up @@ -33,7 +32,6 @@ Object {

exports[`runAsyncTest: passing State updates Initial state matches snapshot (sanity) 1`] = `
Object {
"carryOverTests": Array [],
"lagging": Array [],
"optionalFields": Object {},
"pending": Array [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

exports[`module: pending export: removePending When testObject is either pending or lagging When in lagging Should remove test from lagging 1`] = `
Object {
"carryOverTests": Array [],
"lagging": Array [],
"optionalFields": Object {},
"pending": Array [],
Expand All @@ -19,7 +18,6 @@ Object {

exports[`module: pending export: removePending When testObject is either pending or lagging When in pending Should remove test from pending 1`] = `
Object {
"carryOverTests": Array [],
"lagging": Array [],
"optionalFields": Object {},
"pending": Array [],
Expand All @@ -36,7 +34,6 @@ Object {

exports[`module: pending export: setPending Should set supplied test object as pending 1`] = `
Object {
"carryOverTests": Array [],
"lagging": Array [],
"optionalFields": Object {},
"pending": Array [
Expand Down Expand Up @@ -65,7 +62,6 @@ Object {

exports[`module: pending export: setPending When a field of the same profile is in lagging array Should remove test from lagging array 1`] = `
Object {
"carryOverTests": Array [],
"lagging": Array [
VestTest {
"canceled": false,
Expand Down
6 changes: 3 additions & 3 deletions packages/vest/src/core/test/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import {
import bindTestEach from 'test.each';
import bindTestMemo from 'test.memo';

export function testBase(
function testBase(
fieldName: string,
...args: [message: string, cb: TTestFn]
): VestTest;
export function testBase(fieldName: string, ...args: [cb: TTestFn]): VestTest;
export function testBase(
function testBase(fieldName: string, ...args: [cb: TTestFn]): VestTest;
function testBase(
fieldName: string,
...args: [message: string, cb: TTestFn] | [cb: TTestFn]
): VestTest {
Expand Down

0 comments on commit 40ef071

Please sign in to comment.