mirror of
https://github.com/vercel/eve.git
synced 2026-09-20 05:35:39 +08:00
8b38fabaeb
Signed-off-by: Colton Padden <colton.padden@vercel.com>
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
canonicalAlternates,
|
|
canonicalPathname,
|
|
canonicalRoutes,
|
|
integrationPath,
|
|
templatePath,
|
|
} from "./canonical";
|
|
|
|
describe("canonical routes", () => {
|
|
it("uses one path model for hubs and detail pages", () => {
|
|
expect(canonicalRoutes).toEqual({
|
|
home: "/",
|
|
benchmarks: "/benchmarks",
|
|
integrations: "/integrations",
|
|
templates: "/templates",
|
|
});
|
|
expect(integrationPath("slack")).toBe("/integrations/slack");
|
|
expect(templatePath("eve-chat-template")).toBe("/templates/eve-chat-template");
|
|
});
|
|
|
|
it("removes query and fragment variants from canonical paths", () => {
|
|
expect(canonicalPathname("/integrations?filter=channel")).toBe("/integrations");
|
|
expect(canonicalPathname("/docs/channels/overview#which-channel")).toBe(
|
|
"/docs/channels/overview",
|
|
);
|
|
});
|
|
|
|
it("preserves alternate representations while setting the HTML canonical", () => {
|
|
expect(
|
|
canonicalAlternates("/docs/channels/overview?view=all", {
|
|
types: { "text/markdown": "/docs/channels/overview.md" },
|
|
}),
|
|
).toEqual({
|
|
canonical: "/docs/channels/overview",
|
|
types: { "text/markdown": "/docs/channels/overview.md" },
|
|
});
|
|
});
|
|
|
|
it.each(["https://other.example/docs", "//other.example/docs"])(
|
|
"rejects cross-origin canonical value %s",
|
|
(value) => {
|
|
expect(() => canonicalPathname(value)).toThrow("Canonical path must be site-relative");
|
|
},
|
|
);
|
|
});
|