UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

43 lines (42 loc) 1.92 kB
import { describe, expect, it } from "vitest"; import { normalizeLinkingConfig } from "../link/getLinking.mjs"; import { getRoutes } from "./getRoutes.mjs"; import { getLinkingConfig } from "./getLinkingConfig.mjs"; import { getMockContext } from "../testing-utils.mjs"; describe("getLinkingConfig", () => { it("expands configured schemes into prefixes", () => { const routes = getRoutes(getMockContext(["_layout.tsx", "index.tsx"])); const linking = getLinkingConfig(routes, true, { scheme: "threepunchconvo" }); expect(linking.prefixes).toEqual(["threepunchconvo://", "threepunchconvo:///"]); }); it("merges explicit prefixes with scheme-derived prefixes", () => { const routes = getRoutes(getMockContext(["_layout.tsx", "index.tsx"])); const linking = getLinkingConfig(routes, true, { scheme: "threepunchconvo", prefixes: ["threepunchconvo://app"] }); expect(linking.prefixes).toEqual(["threepunchconvo://", "threepunchconvo:///", "threepunchconvo://app"]); }); }); describe("normalizeLinkingConfig", () => { it("merges manifest-default prefixes with user-supplied scheme/prefixes", () => { const result = normalizeLinkingConfig({ scheme: "foo", prefixes: ["https://example.test/app"] }, ["bar://", "bar:///"]); expect(result.prefixes).toEqual(["bar://", "bar:///", "foo://", "foo:///", "https://example.test/app"]); }); it("falls back to manifest-default prefixes when nothing is configured", () => { const result = normalizeLinkingConfig(void 0, ["bar://", "bar:///"]); expect(result.prefixes).toEqual(["bar://", "bar:///"]); }); it("dedupes overlapping defaults and configured prefixes", () => { const result = normalizeLinkingConfig({ scheme: "foo" }, ["foo://", "foo:///"]); expect(result.prefixes).toEqual(["foo://", "foo:///"]); }); }); //# sourceMappingURL=getLinkingConfig.test.mjs.map