Some checks failed
Build and publish Docker image / docker (push) Failing after 2m33s
34 lines
842 B
TypeScript
34 lines
842 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { validateSources } from "@/lib/moderation";
|
|
|
|
describe("validateSources", () => {
|
|
it("requires at least one source", () => {
|
|
expect(validateSources([])).toContain("missing_sources");
|
|
});
|
|
|
|
it("requires a valid URL and license", () => {
|
|
expect(
|
|
validateSources([
|
|
{
|
|
title: "Archive",
|
|
url: "not-a-url",
|
|
language: "DE",
|
|
},
|
|
]),
|
|
).toEqual(expect.arrayContaining(["source_invalid_url", "source_missing_license"]));
|
|
});
|
|
|
|
it("accepts sourced material with licensing metadata", () => {
|
|
expect(
|
|
validateSources([
|
|
{
|
|
title: "Public record",
|
|
url: "https://example.org/source",
|
|
language: "EN",
|
|
license: "CC BY 4.0",
|
|
},
|
|
]),
|
|
).toEqual([]);
|
|
});
|
|
});
|