Skip to content

Commit

Permalink
Feat:Test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
crystal4000 committed Jul 24, 2024
1 parent 5f52e72 commit a9e898e
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions src/app/(auth-routes)/login/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,43 @@ type FieldType = {
};

vi.mock("~/components/ui/form", () => ({
Form: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
FormField: ({
Form: function Form({ children }: { children: React.ReactNode }) {
return <div>{children}</div>;
},
FormField: function FormField({
render,
}: {
render: (properties: { field: FieldType }) => React.ReactNode;
}) =>
render({
}) {
return render({
field: {
onChange: vi.fn(),
onBlur: vi.fn(),
value: "",
name: "",
ref: () => {},
},
}),
FormItem: ({ children }: { children: React.ReactNode }) => (
<div>{children}</div>
),
FormLabel: ({ children }: { children: React.ReactNode }) => (
<label>{children}</label>
),
FormControl: ({ children }: { children: React.ReactNode }) => (
<div>{children}</div>
),
FormMessage: ({ children }: { children: React.ReactNode }) => children,
});
},
FormItem: function FormItem({ children }: { children: React.ReactNode }) {
return <div>{children}</div>;
},
FormLabel: function FormLabel({ children }: { children: React.ReactNode }) {
return <label>{children}</label>;
},
FormControl: React.forwardRef(function FormControl(
{ children }: { children: React.ReactNode },
reference: React.Ref<HTMLDivElement>,
) {
return <div ref={reference}>{children}</div>;
}),
FormMessage: function FormMessage({
children,
}: {
children: React.ReactNode;
}) {
return children;
},
}));

vi.mock("~/components/ui/input", () => ({
Expand Down

0 comments on commit a9e898e

Please sign in to comment.