Skip to content

Commit ef8c6b8

Browse files
committed
Restoring env test on transformation examples, rm unused snapshots.
1 parent 7995e7b commit ef8c6b8

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

express-zod-api/tests/__snapshots__/env.spec.ts.snap

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,23 +249,25 @@ exports[`Environment checks > Zod imperfections > circular object schema has no
249249
}
250250
`;
251251

252-
exports[`Environment checks > Zod imperfections > input examples of transformations 1`] = `
252+
exports[`Environment checks > Zod imperfections > meta overrides, does not merge 1`] = `
253253
{
254-
"examples": [
255-
4,
256-
],
257-
"type": "string",
254+
"title": "last",
258255
}
259256
`;
260257

261-
exports[`Environment checks > Zod imperfections > meta overrides, does not merge 1`] = `
258+
exports[`Environment checks > Zod new features > input examples of transformations 1`] = `
262259
{
263-
"title": "last",
260+
"$schema": "https://json-schema.org/draft-2020-12/schema",
261+
"examples": [
262+
"test",
263+
],
264+
"type": "string",
264265
}
265266
`;
266267

267-
exports[`Environment checks > Zod imperfections > output examples of transformations 1`] = `
268+
exports[`Environment checks > Zod new features > output examples of transformations 1`] = `
268269
{
270+
"$schema": "https://json-schema.org/draft-2020-12/schema",
269271
"examples": [
270272
4,
271273
],

express-zod-api/tests/env.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ describe("Environment checks", () => {
125125
expect(boolSchema.isOptional()).toBeTruthy();
126126
expect(boolSchema.isNullable()).toBeTruthy();
127127
});
128+
129+
/**
130+
* @link https://github.com/colinhacks/zod/issues/4274
131+
* @todo this fact can be used for switching to native examples
132+
* */
133+
test.each(["input", "output"] as const)(
134+
"%s examples of transformations",
135+
(io) => {
136+
const schema = z
137+
.string()
138+
.meta({ examples: ["test"] })
139+
.transform(Number)
140+
.meta({ examples: [4] });
141+
expect(
142+
z.toJSONSchema(schema, { io, unrepresentable: "any" }),
143+
).toMatchSnapshot();
144+
},
145+
);
128146
});
129147

130148
describe("Vitest error comparison", () => {

0 commit comments

Comments
 (0)