From 654d0b3715caa3dd56ac0b4d429848b805a4c6f9 Mon Sep 17 00:00:00 2001 From: Erik Brinkman Date: Thu, 4 Apr 2024 00:08:21 -0400 Subject: [PATCH] add validate test --- src/validate.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 src/validate.test.ts diff --git a/src/validate.test.ts b/src/validate.test.ts new file mode 100644 index 0000000..d8cc371 --- /dev/null +++ b/src/validate.test.ts @@ -0,0 +1,18 @@ +import { UploadEntry } from "."; +import { JtdSchema, validate } from "./validate"; + +const uploadEntrySchema: JtdSchema = { + properties: { + docID: { type: "string" }, + hash: { type: "string" }, + }, +}; + +test("validate()", () => { + const accurate = { docID: "", hash: "" }; + expect(() => validate(uploadEntrySchema, accurate)).not.toThrow(); + + const innaccurate = { docID: "" }; + expect(() => validate(uploadEntrySchema, innaccurate)).toThrow(); + expect(() => validate(uploadEntrySchema, innaccurate, false)).not.toThrow(); +});