forked from MapComplete/MapComplete
Tests: test that every validator has a matching type and vice-versa
This commit is contained in:
parent
2147b8d368
commit
adee925d8c
1 changed files with 25 additions and 0 deletions
25
test/UI/Validators.spec.ts
Normal file
25
test/UI/Validators.spec.ts
Normal file
|
@ -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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in a new issue