mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-13 21:01:21 +08:00
53 lines
1.3 KiB
TypeScript
53 lines
1.3 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { typeAssertExtends } from "./utils/types";
|
|
import { defineStackConfig, type StackConfig } from "./config-authoring";
|
|
|
|
const validConfig = defineStackConfig({
|
|
payments: {
|
|
items: {
|
|
todos: {
|
|
displayName: "Todo Slots",
|
|
customerType: "user",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
const showOnboardingConfig = defineStackConfig("show-onboarding");
|
|
|
|
typeAssertExtends<typeof validConfig, StackConfig>()();
|
|
typeAssertExtends<typeof showOnboardingConfig, StackConfig>()();
|
|
|
|
it("returns its input unchanged", () => {
|
|
expect(defineStackConfig(validConfig)).toBe(validConfig);
|
|
expect(defineStackConfig(showOnboardingConfig)).toBe(showOnboardingConfig);
|
|
});
|
|
|
|
defineStackConfig({
|
|
// @ts-expect-error Top-level dot notation should not be accepted in typed config files.
|
|
"payments.items": {
|
|
todos: {
|
|
displayName: "Todo Slots",
|
|
customerType: "user",
|
|
},
|
|
},
|
|
});
|
|
|
|
defineStackConfig({
|
|
payments: {
|
|
// @ts-expect-error Unknown keys should not be accepted in typed config files.
|
|
missingField: true,
|
|
},
|
|
});
|
|
|
|
defineStackConfig({
|
|
payments: {
|
|
items: {
|
|
todos: {
|
|
displayName: "Todo Slots",
|
|
// @ts-expect-error Invalid enum values should fail type-checking.
|
|
customerType: "workspace",
|
|
},
|
|
},
|
|
},
|
|
});
|