mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-04-01 21:13:11 +00:00
chore: Fix the tests and add new types for raw
This commit is contained in:
23
lib/test/configTypes.test.ts
Normal file
23
lib/test/configTypes.test.ts
Normal 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));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user