Skip to content

Commit

Permalink
Update: remove test files from prod bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrywithaz committed Sep 18, 2023
1 parent ae3b4b3 commit 24f907b
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { ArrayFieldProps } from "../ArrayField.types";
import SubmitButton from "../../SubmitButton";
import Field, { FieldProps } from "../../Field";
import ErrorMessage from "../../ErrorMessage";
import { formzStore, defaultTestFormName, createDefaultFormzState } from "@zerry/react-formz-core";
import { formzStore } from "@zerry/react-formz-core";
import TestFieldComponent from "../../../../testUtils/TestFieldComponent";
import { defaultTestFormName } from "../../../../testUtils/constants";
import createDefaultFormzState from "../../../../testUtils/createDefaultFormzState";

type FormState = {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import Field, { FieldProps } from "../../Field";
import subYears from "date-fns/subYears";
import format from "date-fns/format";
import TestFieldComponent from "../../../../testUtils/TestFieldComponent";
import { formzStore, defaultTestFormName, createDefaultFormzState } from "@zerry/react-formz-core";
import { formzStore } from "@zerry/react-formz-core";
import { defaultTestFormName } from "../../../../testUtils/constants";
import createDefaultFormzState from "../../../../testUtils/createDefaultFormzState";

type FormState = {
name: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import Field from "../Field";
import userEvent from "@testing-library/user-event";
import SubmitButton from "../../SubmitButton";
import TestFieldComponent from "../../../../testUtils/TestFieldComponent";
import { formzStore, defaultTestFormName, createDefaultFormzState } from "@zerry/react-formz-core";
import { formzStore } from "@zerry/react-formz-core";
import { WebFieldProps } from "../Field.types";
import { defaultTestFormName } from "../../../../testUtils/constants";
import createDefaultFormzState from "../../../../testUtils/createDefaultFormzState";

function resetState() {
() => {
Expand Down
1 change: 1 addition & 0 deletions packages/react-formz-web/testUtils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const defaultTestFormName = "test";
24 changes: 24 additions & 0 deletions packages/react-formz-web/testUtils/createDefaultFormzState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FormzState, FormzValues } from "@zerry/react-formz-core";

function createDefaultFormzState<Values extends FormzValues>(partial?: Partial<FormzState<Values>> ): FormzState<Values> {
const state: FormzState<Values> = {
values: {} as Values,
errors: {},
isInvalid: false,
isSubmitting: false,
isValidating: false,
initialValues: {} as Values,
initialized: true,
touched: {},
submitCount: 0,
saveDrafts: false,
lastPersistedAt: null,
hydrated: false,
restoredFromDate: null,
...partial,
};

return state;
}

export default createDefaultFormzState;
2 changes: 0 additions & 2 deletions packages/react-formz/index.ts

This file was deleted.

9 changes: 6 additions & 3 deletions packages/react-formz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"packageManager": "yarn@3.2.3",
"license": "MIT",
"sideEffects": false,
"main": "./index.ts",
"types": "./index.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"devDependencies": {
"@babel/core": "^7.19.0",
"@babel/preset-env": "^7.19.0",
Expand Down Expand Up @@ -63,5 +63,8 @@
},
"publishConfig": {
"access": "public"
}
},
"files": [
"dist"
]
}
1 change: 1 addition & 0 deletions packages/react-formz/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export type {
FormRehydrationCallback,
FormSubmitCallback,
FormProps,
FormzState
} from "./types/form";
export type { LiteralUnion } from "./types/utils";

Expand Down

0 comments on commit 24f907b

Please sign in to comment.