import { BlockSection } from "@milaboratories/pl-model-common"; import { test } from "vitest"; import { DeriveHref } from "./bconfig"; type AssertEqual = [T] extends [Expected] ? [Expected] extends [T] ? true : false : false; export const assertType = ( ..._: AssertEqual extends true ? [] : ["invalid type"] ) => { // noop }; type AssertExtends = T extends Expected ? true : false; export const assertTypeExtends = ( ..._: AssertExtends extends true ? [] : ["invalid type"] ) => { // noop }; function testCreateSections(_sections: () => S): DeriveHref { return undefined as any; } test("href derivation from sections", () => { const s1 = testCreateSections(() => [ { type: "delimiter" }, { type: "link", href: "/a1", label: "l" }, { type: "link", href: "/a2", label: "ls" }, ]); assertType(); const s2 = testCreateSections(() => [{ type: "delimiter" }]); assertType(); });