Study/src/lib/shareMetadata.test.ts

34 lines
876 B
TypeScript

import { describe, expect, it } from "vitest";
import { buildShareMetadata, type ShareMetaLink } from "./shareMetadata";
describe("buildShareMetadata", () => {
const deckLink: ShareMetaLink = {
targetType: "DECK",
deck: {
name: "Deck",
description: null,
class: { slug: "class", name: "Class" },
_count: { cards: 3 },
},
quizSet: null,
group: null,
};
it("does not describe a token under a mismatched shared route type", () => {
expect(
buildShareMetadata(deckLink, {
classSlug: "class",
pathType: "quizzes",
}).title
).toBe("Study Desk");
});
it("describes the target only when token, class, and route type agree", () => {
expect(
buildShareMetadata(deckLink, {
classSlug: "class",
pathType: "flashcards",
}).title
).toContain("Deck");
});
});