Skip to content

Commit

Permalink
add validate test
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbrinkman committed Apr 4, 2024
1 parent 24ade47 commit 654d0b3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/validate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { UploadEntry } from ".";
import { JtdSchema, validate } from "./validate";

const uploadEntrySchema: JtdSchema<UploadEntry> = {
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();
});

0 comments on commit 654d0b3

Please sign in to comment.