Skip to content

Commit

Permalink
patch(vest): simplify flat test selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Apr 26, 2022
1 parent 679b1ca commit 69ff658
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions packages/vest/src/core/state/stateHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ export function useTestObjects(): StateKey<'testObjects'> {
// STATE ACTIONS

export function useRefreshTestObjects(): void {
const [, setTestObjects] = useTestObjects();

setTestObjects(({ current, prev }) => ({
prev,
current: asArray(current),
}));
useSetTests(tests => tests);
}

export function useSetTests(
Expand All @@ -97,13 +92,7 @@ export function useSetTests(
// Derived state

export function useAllIncomplete(): VestTest[] {
const [{ current }] = useTestObjects();

return nestedArray.flatten(
nestedArray.transform(current, testObject =>
testObject.isPending() ? testObject : null
)
);
return useTestsFlat().filter(test => test.isPending());
}

const flatCache = createCache();
Expand Down

0 comments on commit 69ff658

Please sign in to comment.