Skip to content

Commit

Permalink
make conditions a discriminated union
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPHoughton committed Nov 1, 2024
1 parent 087d53c commit 6ba23d4
Show file tree
Hide file tree
Showing 2 changed files with 408 additions and 244 deletions.
43 changes: 21 additions & 22 deletions server/src/preFlight/validateTreatmentFile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { expect, test } from "vitest";
import {
referenceSchema,
conditionSchema,
introConditionSchema,
elementsSchema,
promptSchema,
topSchema,
Expand Down Expand Up @@ -74,28 +73,28 @@ test("condition missing required value", () => {
expect(result.success).toBe(false);
});

test("condition in intro valid", () => {
const condition = {
reference: "prompt.namedPrompt",
comparator: "equals",
value: "value",
};
const result = introConditionSchema.safeParse(condition);
if (!result.success) console.log(result.error.message);
expect(result.success).toBe(true);
});
// test("condition in intro valid", () => {
// const condition = {
// reference: "prompt.namedPrompt",
// comparator: "equals",
// value: "value",
// };
// const result = introConditionSchema.safeParse(condition);
// if (!result.success) console.log(result.error.message);
// expect(result.success).toBe(true);
// });

test("condition in intro errors on position", () => {
const condition = {
reference: "prompt.namedPrompt",
comparator: "equals",
value: "value",
position: 1,
};
const result = introConditionSchema.safeParse(condition);
if (!result.success) console.log(result.error.message);
expect(result.success).toBe(false);
});
// test("condition in intro errors on position", () => {
// const condition = {
// reference: "prompt.namedPrompt",
// comparator: "equals",
// value: "value",
// position: 1,
// };
// const result = introConditionSchema.safeParse(condition);
// if (!result.success) console.log(result.error.message);
// expect(result.success).toBe(false);
// });

// ----------- Small schemas ------------

Expand Down
Loading

0 comments on commit 6ba23d4

Please sign in to comment.