Skip to content

Commit

Permalink
tests not finished
Browse files Browse the repository at this point in the history
  • Loading branch information
KryptXBSA committed Dec 2, 2024
1 parent 3529458 commit 802bc55
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 336 deletions.
2 changes: 1 addition & 1 deletion apps/web/src/app/test/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const language = [
{ label: "Arabic", value: "ar" },
{ label: "Kurdish", value: "ku" },
]
export function MyForm() {
export default function MyForm() {
const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema),
defaultValues: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/codegen/generate-code.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { FormField, FormSchema } from "@/schema";
import type { FormSchema } from "@/schema";
import Handlebars from "handlebars";

import { generateImports } from "./imports/index";
Expand Down
41 changes: 33 additions & 8 deletions packages/core/test/codegen.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
import { expect, test } from "bun:test";
import { generateCode } from "../src/codegen/generate-code";
import { mockFields } from "../src/mock/mockFields";
import { toBe } from "./mock";
import {
mainTemplate,
stringInputTemplate,
numberInputTemplate,
booleanInputTemplate,
dateInputTemplate,
selectInputTemplate,
radioInputTemplate,
comboboxInputTemplate,
textareaInputTemplate,
} from "../src/codegen/templates";
import type { FormSchema } from "@/schema";

test("test generate code", () => {
const code = generateCode({
name: "test",
fields: mockFields,
});
expect(code).toBeDefined();
Bun.write("./apps/web/src/app/test/page.tsx", code);
// expect(code).toBe(toBe);
const form: FormSchema = {
name: "TestForm",
fields: [
{
id: "1",
label: "Name",
key: "name",
kind: "string",
required: true,
},
{
id: "2",
label: "Age",
key: "age",
kind: "number",
required: false,
},
],
};
const generatedCode = generateCode(form);
expect(generatedCode).toBe();
});
Empty file.
326 changes: 0 additions & 326 deletions packages/core/test/mock.ts

This file was deleted.

0 comments on commit 802bc55

Please sign in to comment.