1
mirror of https://github.com/jakejarvis/hugo-extended.git synced 2026-06-24 10:25:57 -04:00
Files
hugo-extended/tests/unit/types.test.ts
T
jake f111ebd21e fix: rename new site to new project to match Hugo v0.156.0
Hugo v0.156.0 renamed the `new site` subcommand to `new project`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 10:33:35 -05:00

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 project">().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 NewProjectOpts = HugoOptionsFor<"new project">;
type NewThemeOpts = HugoOptionsFor<"new theme">;
// Build options should have minify
expectTypeOf<BuildOpts>().toHaveProperty("minify");
// Server options should have port
expectTypeOf<ServerOpts>().toHaveProperty("port");
// New project options should have format
expectTypeOf<NewProjectOpts>().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");
});
});