3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-18 15:00:00 +00:00
zeppelin/backend/src/validation.test.ts

41 lines
859 B
TypeScript
Raw Normal View History

import { tDeepPartial } from "./utils";
import * as t from "io-ts";
import * as validatorUtils from "./validatorUtils";
import test from "ava";
test("tDeepPartial works", ava => {
const originalSchema = t.type({
listOfThings: t.record(
t.string,
t.type({
enabled: t.boolean,
someValue: t.number,
}),
),
});
const deepPartialSchema = tDeepPartial(originalSchema);
const partialValidValue = {
listOfThings: {
myThing: {
someValue: 5,
},
},
};
const partialErrorValue = {
listOfThings: {
myThing: {
someValue: "test",
},
},
};
const result1 = validatorUtils.validate(deepPartialSchema, partialValidValue);
ava.is(result1, null);
const result2 = validatorUtils.validate(deepPartialSchema, partialErrorValue);
ava.not(result2, null);
});