Skip to content

Commit

Permalink
patch(vest): add VestIsolate class
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Nov 28, 2023
1 parent 8bc8e1c commit 5c435f9
Show file tree
Hide file tree
Showing 9 changed files with 498 additions and 443 deletions.
6 changes: 3 additions & 3 deletions packages/vest-utils/src/SimpleStateMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CB } from 'utilityTypes';
const STATE_WILD_CARD = '*';
type TStateWildCard = typeof STATE_WILD_CARD;

export type TStateMachine<S extends string, A extends S = S> = {
export type TStateMachine<S extends string = string, A extends S = S> = {
initial: S;
states: Partial<{
[key in S & TStateWildCard]: {

Check warning on line 9 in packages/vest-utils/src/SimpleStateMachine.ts

View workflow job for this annotation

GitHub Actions / build (20)

'key' is defined but never used. Allowed unused vars must match /^_/u
Expand All @@ -12,14 +12,14 @@ export type TStateMachine<S extends string, A extends S = S> = {
}>;
};

export type TStateMachineApi<S extends string, A extends S = S> = {
export type TStateMachineApi<S extends string = string, A extends S = S> = {
getState: CB<S>;
initial: CB<S>;
staticTransition: (from: S, action: A, payload?: any) => S;
transition: (action: A, payload?: any) => void;
};

export function StateMachine<S extends string, A extends S = S>(
export function StateMachine<S extends string = string, A extends S = S>(
machine: TStateMachine<S, A>
): TStateMachineApi<S, A> {
let state = machine.initial;
Expand Down
6 changes: 5 additions & 1 deletion packages/vest-utils/src/vest-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export { isArray, isNotArray } from 'isArrayValue';
export { isEmpty, isNotEmpty } from 'isEmpty';
export { isPositive } from 'isPositive';
export { text } from 'text';
export { TStateMachine, StateMachine } from 'SimpleStateMachine';
export {
TStateMachine,
StateMachine,
TStateMachineApi,
} from 'SimpleStateMachine';
export { nonnullish } from 'nonnullish';
export * as tinyState from 'tinyState';
export { StringObject } from 'StringObject';
Expand Down
352 changes: 352 additions & 0 deletions packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,358 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`useLoadSuite Calling useLoadSuite should resume from loaded state 1`] = `
{
"$type": "Suite",
"abortController": AbortController {},
"allowReorder": undefined,
"children": [
{
"$type": "Focused",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"focusMode": 1,
"match": [
"t5",
],
"matchAll": false,
},
"key": null,
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "DONE",
},
{
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t1",
"severity": "error",
"testFn": [Function],
},
"key": null,
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "FAILED",
},
{
"$type": "Group",
"abortController": AbortController {},
"allowReorder": undefined,
"children": [
{
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t2",
"groupName": "g1",
"message": "t2 message",
"severity": "error",
"testFn": [Function],
},
"key": null,
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "FAILED",
},
{
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t3",
"groupName": "g1",
"severity": "error",
"testFn": [Function],
},
"key": null,
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "PASSING",
},
{
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t4",
"groupName": "g1",
"severity": "warning",
"testFn": [Function],
},
"key": null,
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "WARNING",
},
],
"data": {},
"key": null,
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "DONE",
},
{
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t5",
"severity": "error",
"testFn": [Function],
},
"key": null,
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "SKIPPED",
},
{
"$type": "Each",
"abortController": AbortController {},
"allowReorder": true,
"children": [
{
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t6",
"severity": "error",
"testFn": [Function],
},
"key": "a",
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "FAILED",
},
{
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t6",
"severity": "error",
"testFn": [Function],
},
"key": "b",
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "FAILED",
},
],
"data": {},
"key": null,
"keys": {
"a": {
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t6",
"severity": "error",
"testFn": [Function],
},
"key": "a",
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "FAILED",
},
"b": {
"$type": "Test",
"abortController": AbortController {},
"allowReorder": undefined,
"children": null,
"data": {
"fieldName": "t6",
"severity": "error",
"testFn": [Function],
},
"key": "b",
"keys": null,
"output": undefined,
"parent": [Circular],
"status": "FAILED",
},
},
"output": undefined,
"parent": [Circular],
"status": "DONE",
},
],
"data": {
"optional": {},
},
"key": null,
"keys": null,
"output": {
"done": [Function],
"errorCount": 4,
"errors": [
SummaryFailure {
"fieldName": "t1",
"groupName": undefined,
"message": undefined,
},
SummaryFailure {
"fieldName": "t2",
"groupName": "g1",
"message": "t2 message",
},
SummaryFailure {
"fieldName": "t6",
"groupName": undefined,
"message": undefined,
},
SummaryFailure {
"fieldName": "t6",
"groupName": undefined,
"message": undefined,
},
],
"getError": [Function],
"getErrors": [Function],
"getErrorsByGroup": [Function],
"getWarning": [Function],
"getWarnings": [Function],
"getWarningsByGroup": [Function],
"groups": {
"g1": {
"t2": SummaryBase {
"errorCount": 1,
"errors": [
"t2 message",
],
"pendingCount": 0,
"testCount": 1,
"valid": false,
"warnCount": 0,
"warnings": [],
},
"t3": SummaryBase {
"errorCount": 0,
"errors": [],
"pendingCount": 0,
"testCount": 1,
"valid": true,
"warnCount": 0,
"warnings": [],
},
"t4": SummaryBase {
"errorCount": 0,
"errors": [],
"pendingCount": 0,
"testCount": 1,
"valid": true,
"warnCount": 1,
"warnings": [],
},
},
},
"hasErrors": [Function],
"hasErrorsByGroup": [Function],
"hasWarnings": [Function],
"hasWarningsByGroup": [Function],
"isPending": [Function],
"isValid": [Function],
"isValidByGroup": [Function],
"pendingCount": 0,
"suiteName": undefined,
"testCount": 6,
"tests": {
"t1": SummaryBase {
"errorCount": 1,
"errors": [],
"pendingCount": 0,
"testCount": 1,
"valid": false,
"warnCount": 0,
"warnings": [],
},
"t2": SummaryBase {
"errorCount": 1,
"errors": [
"t2 message",
],
"pendingCount": 0,
"testCount": 1,
"valid": false,
"warnCount": 0,
"warnings": [],
},
"t3": SummaryBase {
"errorCount": 0,
"errors": [],
"pendingCount": 0,
"testCount": 1,
"valid": true,
"warnCount": 0,
"warnings": [],
},
"t4": SummaryBase {
"errorCount": 0,
"errors": [],
"pendingCount": 0,
"testCount": 1,
"valid": true,
"warnCount": 1,
"warnings": [],
},
"t5": SummaryBase {
"errorCount": 0,
"errors": [],
"pendingCount": 0,
"testCount": 0,
"valid": false,
"warnCount": 0,
"warnings": [],
},
"t6": {
"errorCount": 2,
"errors": [],
"pendingCount": 0,
"testCount": 2,
"valid": false,
"warnCount": 0,
"warnings": [],
},
},
"valid": false,
"warnCount": 1,
"warnings": [
SummaryFailure {
"fieldName": "t4",
"groupName": "g1",
"message": undefined,
},
],
},
"parent": null,
"status": "DONE",
}
`;

exports[`useLoadSuite Calling useLoadSuite should resume from loaded state 2`] = `
SuiteSummary {
"errorCount": 4,
"errors": [
Expand Down
Loading

2 comments on commit 5c435f9

@vercel
Copy link

@vercel vercel bot commented on 5c435f9 Nov 28, 2023

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-next-git-latest-ealush.vercel.app
vest-next-ealush.vercel.app
vest-website.vercel.app
vest-next.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 5c435f9 Nov 28, 2023

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 – ./website

vest-ealush.vercel.app
vest.vercel.app
vest-git-latest-ealush.vercel.app
vestjs.dev
www.vestjs.dev

Please sign in to comment.