Skip to content

Commit

Permalink
Merge pull request #156 from InseeFr/feat/bump-zod
Browse files Browse the repository at this point in the history
feat: bump zod
  • Loading branch information
EmmanuelDemey authored Oct 22, 2024
2 parents b36bb36 + b37ce59 commit d9b9745
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"react-hook-form": "^7.49.2",
"react-router-dom": "^6.21.0",
"react-swipeable-views": "^0.14.0",
"zod": "^3.22.4"
"zod": "^3.23.8"
},
"scripts": {
"dev": "vite",
Expand Down
72 changes: 71 additions & 1 deletion src/utils/schemas.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,76 @@
import {
communicationMediumEnum,
communicationReasonEnum,
communicationTypeEnum,
} from 'utils/enum/CommunicationEnums';
import { describe, it } from 'vitest';
import { userSchema } from './schemas';
import { communicationSchema, recipientSchema, userSchema } from './schemas';

describe('schemas', () => {
describe('recipientSchema', () => {
test.each([
[{}, false],
[{ title: 'MISS' }, false],
[{ title: 'MISS', firstName: 'firstName' }, false],
[{ title: 'MISS', firstName: 'firstName', lastName: 'lastName' }, false],
[
{ title: 'MISS', firstName: 'firstName', lastName: 'lastName', postCode: 'postCode' },
false,
],
[
{
title: 'MISS',
firstName: 'firstName',
lastName: 'lastName',
postCode: 'postCode',
cityName: 'cityName',
},
true,
],
])('expect %o validity -> %s', (data, isValid) => {
const expectation = expect(() => recipientSchema.parse({ ...data }));
if (isValid) {
expectation.not.toThrow();
} else {
expectation.toThrow();
}
});
});

describe('communicationSchema', () => {
test.each([
[{}, false],
[
{
medium: communicationMediumEnum.MEDIUM_MAIL.type,
},
false,
],
[
{
medium: communicationMediumEnum.MEDIUM_MAIL.type,
type: communicationTypeEnum.COMMUNICATION_NOTICE.type,
},
false,
],
[
{
medium: communicationMediumEnum.MEDIUM_MAIL.type,
type: communicationTypeEnum.COMMUNICATION_NOTICE.type,
reason: communicationReasonEnum.UNREACHABLE.type,
},
true,
],
])('expect %o validity -> %s', (data, isValid) => {
const expectation = expect(() => communicationSchema.parse({ ...data }));
if (isValid) {
expectation.not.toThrow();
} else {
expectation.toThrow();
}
});
});

describe('userSchema', () => {
const validUser = {
title: 'MISTER',
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6366,7 +6366,7 @@ yocto-queue@^0.1.0:
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

zod@^3.22.4:
version "3.22.4"
resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.4.tgz#f31c3a9386f61b1f228af56faa9255e845cf3fff"
integrity sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==
zod@^3.23.8:
version "3.23.8"
resolved "https://registry.yarnpkg.com/zod/-/zod-3.23.8.tgz#e37b957b5d52079769fb8097099b592f0ef4067d"
integrity sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==

0 comments on commit d9b9745

Please sign in to comment.