content-explorer/ui/lib/attribution.test.ts
tegwick f8c94d3272
All checks were successful
synthetic / suite (push) Successful in 56s
Finish the computing-basics pilot and the local OnCo reference slice.
The single-operator pilot keeps static projection. Local OnCo use requires a CC BY-NC origin notice, and the slice stays out of public CI.

Assistant: grok
Assistant-Session: 01a15378-f601-7fe2-a143-8e1500a1d59c
2026-10-19 13:04:55 +02:00

26 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { attributionGaps, uniqueOriginNotices, type SourceCredit } from "./attribution";
const onco: SourceCredit = {
title: "OnCo",
license: "CC-BY-NC-4.0",
uri: "https://onco.cc",
attribution: "Data from OnCo (onco.cc)",
licenseUrl: "https://creativecommons.org/licenses/by-nc/4.0/",
retrievedAt: "2026-10-19",
originSha: "b594d7433bf4e408b44215e25e5304696d6f840e",
modificationNotice: "Projected from the pinned record.",
};
describe("attribution", () => {
it("accepts a complete CC BY-NC notice and rejects a missing duty", () => {
expect(attributionGaps(onco)).toEqual([]);
expect(attributionGaps({ ...onco, modificationNotice: "" })).toContain("modificationNotice");
expect(attributionGaps({ ...onco, licenseUrl: "https://example.invalid" })).toContain("licenseUrl");
});
it("shows one notice when every record repeats the same origin", () => {
const record = { ...onco, title: "One record", uri: "https://onco.cc/records/one" };
expect(uniqueOriginNotices([onco, record, { title: "Public", license: "CC0-1.0", uri: "https://example.test" }])).toEqual([onco]);
});
});