star-chart-search-enhancer/tests/route-key.test.ts

28 lines
830 B
TypeScript

import { describe, expect, test } from "vitest";
import { createRouteKey } from "../src/shared/route-key";
describe("createRouteKey", () => {
test("uses the page star id when it exists", () => {
expect(
createRouteKey({
navigationSeq: 2,
pageStarId: "6629661559960371207",
pathname: "/ad/creator/author-homepage/douyin-video/6629661559960371207"
})
).toBe(
"6629661559960371207::/ad/creator/author-homepage/douyin-video/6629661559960371207::2"
);
});
test("falls back to unknown when the star id is absent", () => {
expect(
createRouteKey({
navigationSeq: 1,
pageStarId: null,
pathname: "/ad/creator/author-homepage/douyin-video/unknown"
})
).toBe("unknown::/ad/creator/author-homepage/douyin-video/unknown::1");
});
});