Skip to content

Commit

Permalink
patch(vest): Add IsolateTest class
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Oct 1, 2023
1 parent f61b359 commit 3caa744
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 18 deletions.
11 changes: 11 additions & 0 deletions packages/vest/src/core/isolate/IsolateReconciler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { TIsolate } from 'vestjs-runtime';

export abstract class IsolateReconciler {
static match(currentNode: TIsolate, historyNode: TIsolate): boolean {
return false;
}

static reconcile(currentNode: TIsolate, historyNode: TIsolate): TIsolate {
return (currentNode ?? historyNode) as TIsolate;
}
}
30 changes: 18 additions & 12 deletions packages/vest/src/core/isolate/IsolateTest/IsolateTestReconciler.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { IsolateReconciler } from 'IsolateReconciler';
import { Maybe, deferThrow, text } from 'vest-utils';
import { IsolateInspector, Reconciler } from 'vestjs-runtime';
import type { TIsolate } from 'vestjs-runtime';
Expand All @@ -10,20 +11,25 @@ import { castIsolateTest, isIsolateTest } from 'isIsolateTest';
import { isSameProfileTest } from 'isSameProfileTest';
import { useVerifyTestRun } from 'verifyTestRun';

// @vx-allow use-use
export function IsolateTestReconciler(
currentNode: TIsolateTest,
historyNode: TIsolateTest
): TIsolateTest {
const reconcilerOutput = usePickNode(historyNode, currentNode);
export class IsolateTestReconciler extends IsolateReconciler {
static match(currentNode: TIsolate, historyNode: TIsolate): boolean {
return isIsolateTest(currentNode) && isIsolateTest(historyNode);
}

cancelOverriddenPendingTestOnTestReRun(
reconcilerOutput,
currentNode,
historyNode
);
static reconcile(
currentNode: TIsolateTest,
historyNode: TIsolateTest
): TIsolateTest {
const reconcilerOutput = usePickNode(historyNode, currentNode);

return reconcilerOutput;
cancelOverriddenPendingTestOnTestReRun(
reconcilerOutput,
currentNode,
historyNode
);

return reconcilerOutput;
}
}

function usePickNode(
Expand Down
11 changes: 5 additions & 6 deletions packages/vest/src/core/isolate/VestReconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import { Nullable } from 'vest-utils';
import { TIsolate } from 'vestjs-runtime';

import { IsolateTestReconciler } from 'IsolateTestReconciler';
import { isIsolateTest } from 'isIsolateTest';

export function VestReconciler(
currentNode: TIsolate,
historyNode: TIsolate
): Nullable<TIsolate> {
if (isIsolateTest(currentNode) && isIsolateTest(historyNode)) {
return IsolateTestReconciler(currentNode, historyNode);
}

return null;
return (
[IsolateTestReconciler]
.find(reconciler => reconciler.match(currentNode, historyNode))
?.reconcile(currentNode as any, historyNode as any) ?? null
);
}
1 change: 1 addition & 0 deletions packages/vest/tsconfig.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3caa744

Please sign in to comment.