chore: Fix the tests and add new types for raw

This commit is contained in:
BluJ
2023-04-05 13:51:43 -06:00
parent b8d6addf28
commit 45192e0358
19 changed files with 222 additions and 376 deletions

View File

@@ -0,0 +1,23 @@
import { ListValueSpecOf, ValueSpecList, isValueSpecListOf } from "../config/configTypes";
import { Config } from "../config/builder/config";
import { List } from "../config/builder/list";
import { Value } from "../config/builder/value";
describe("Config Types", () => {
test("isValueSpecListOf", () => {
const options = [List.obj, List.string, List.number];
for (const option of options) {
const test = option({} as any, { spec: Config.of({}) } as any) as any;
const someList = Value.list(test).build();
if (isValueSpecListOf(someList, "string")) {
someList.spec satisfies ListValueSpecOf<"string">;
} else if (isValueSpecListOf(someList, "number")) {
someList.spec satisfies ListValueSpecOf<"number">;
} else if (isValueSpecListOf(someList, "object")) {
someList.spec satisfies ListValueSpecOf<"object">;
} else {
throw new Error("Failed to figure out the type: " + JSON.stringify(someList));
}
}
});
});