1
mirror of https://github.com/jakejarvis/hugo-extended.git synced 2026-06-24 12:45:57 -04:00
Files
hugo-extended/tests/unit/types.test.ts
T

42 lines
1.5 KiB
TypeScript

import { describe, expectTypeOf, it } from "vitest";
import type { HugoCommand, HugoOptionsFor } from "../../src/generated/types";
describe("Type Safety", () => {
it("should have correct command types", () => {
// Check that specific commands are valid HugoCommand values
expectTypeOf<"build">().toExtend<HugoCommand>();
expectTypeOf<"server">().toExtend<HugoCommand>();
expectTypeOf<"new site">().toExtend<HugoCommand>();
expectTypeOf<"new theme">().toExtend<HugoCommand>();
expectTypeOf<"new content">().toExtend<HugoCommand>();
});
it("should map commands to correct option types", () => {
type BuildOpts = HugoOptionsFor<"build">;
type ServerOpts = HugoOptionsFor<"server">;
type NewSiteOpts = HugoOptionsFor<"new site">;
type NewThemeOpts = HugoOptionsFor<"new theme">;
// Build options should have minify
expectTypeOf<BuildOpts>().toHaveProperty("minify");
// Server options should have port
expectTypeOf<ServerOpts>().toHaveProperty("port");
// New site options should have format
expectTypeOf<NewSiteOpts>().toHaveProperty("format");
// New theme options should have format
expectTypeOf<NewThemeOpts>().toHaveProperty("format");
});
it("should inherit global options", () => {
type BuildOpts = HugoOptionsFor<"build">;
// All commands should have global options
expectTypeOf<BuildOpts>().toHaveProperty("source");
expectTypeOf<BuildOpts>().toHaveProperty("destination");
expectTypeOf<BuildOpts>().toHaveProperty("environment");
});
});