From adee925d8cf2319a8830a2fea9c8959ec71351d4 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Thu, 22 Jun 2023 17:16:06 +0200 Subject: [PATCH] Tests: test that every validator has a matching type and vice-versa --- test/UI/Validators.spec.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 test/UI/Validators.spec.ts diff --git a/test/UI/Validators.spec.ts b/test/UI/Validators.spec.ts new file mode 100644 index 000000000..fcb5dbb43 --- /dev/null +++ b/test/UI/Validators.spec.ts @@ -0,0 +1,25 @@ +import { describe } from "vitest" +import Validators from "../../UI/InputElement/Validators" + +describe("validators", () => { + it("should have a type for every validator", () => { + const validators = Validators.AllValidators + const knownTypes = Validators.availableTypes + for (const knownType of knownTypes) { + const matchingValidator = validators.find((v) => v.name === knownType) + if (!matchingValidator) { + throw "No validator for available type: " + knownType + } + } + + for (const validator of validators) { + const matchingType = knownTypes.find((v) => v === validator.name) + if (!matchingType) { + throw ( + "No matching type set Validators.availableTypes for available validator: " + + validator.name + ) + } + } + }) +})