Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/validate 3 hours delay and arrivalDate can't be before departureDate #1552

Closed
wants to merge 8 commits into from
Prev Previous commit
Next Next commit
test if specialFieldValidator is called
  • Loading branch information
m0dh4x committed Dec 12, 2024
commit cb0d4272290f8eac9dd65ebe92226cdddf3468df
25 changes: 23 additions & 2 deletions app/services/validation/__test__/buildStepValidator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,19 @@ describe("buildStepValidator", () => {
});

describe("specialFieldValidators", () => {
it("should return a validator for arrival time delay", () => {
it("should return extended validation schema in fluggastrechte flow", async () => {
const schemas = {
tatsaechlicherAnkunftsDatum: z.string(),
tatsaechlicherAnkunftsZeit: z.string(),
direktAbflugsDatum: z.string(),
direktAbflugsZeit: z.string(),
};
const fieldNames = ["tatsaechlicherAnkunftsDatum"];
const fieldNames = [
"tatsaechlicherAnkunftsZeit",
"tatsaechlicherAnkunftsDatum",
"direktAbflugsDatum",
"direktAbflugsZeit",
];

const validator = buildStepValidator(
schemas,
Expand All @@ -119,6 +124,22 @@ describe("buildStepValidator", () => {
);

expect(validator).toBeDefined();

expect(
await validator.validate({
tatsaechlicherAnkunftsDatum: "20.03.2024",
tatsaechlicherAnkunftsZeit: "14:00",
direktAbflugsDatum: "20.03.2024",
direktAbflugsZeit: "13:00",
}),
).toEqual(
expect.objectContaining({
error: {
fieldErrors: { tatsaechlicherAnkunftsZeit: "invalidTimeDelay" },
},
data: undefined,
}),
);
});
});
});