27 lines
1.1 KiB
TypeScript
27 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]);
|
||
|
|
});
|
||
|
|
});
|