Skip to content

Commit

Permalink
test: adding hybrid import
Browse files Browse the repository at this point in the history
  • Loading branch information
tvillaren committed Sep 7, 2023
1 parent 4bee34f commit 503db51
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/core/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,34 @@ describe("generate", () => {
`);
});
});

describe("import as union with object literal", () => {
const sourceText = `
import { Hero } from "module"
export type Person = Hero | { name: string }
`;

const { getZodSchemasFile } = generate({
sourceText,
});

it("should generate the zod schemas", () => {
expect(getZodSchemasFile("./source")).toMatchInlineSnapshot(`
"// Generated by ts-to-zod
import { z } from \\"zod\\";
import { Hero } from \\"module\\";
const heroSchema = z.instanceof(Hero);
export const personSchema = z.union([heroSchema, z.object({
name: z.string()
})]);
"
`);
});
});
});

describe("with input/output mappings to manage imports", () => {
Expand Down

0 comments on commit 503db51

Please sign in to comment.