mirror of
https://github.com/quartz-community/recent-notes.git
synced 2026-07-22 02:50:28 +00:00
Respect the file.data.unlisted convention. Pages marked unlisted are filtered out of the recent notes list before any user-supplied opts.filter runs, so they cannot be accidentally surfaced by a permissive custom filter. Extracts the filter into a named filterListedPages() helper and exports it for reuse and testing. Adds 3 unit tests covering unlisted exclusion, passthrough when nothing is unlisted, and empty-input handling.
36 lines
1 KiB
TypeScript
36 lines
1 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { RecentNotes, filterListedPages } from "../src/index";
|
|
|
|
describe("RecentNotes", () => {
|
|
it("is exported as a function", () => {
|
|
expect(typeof RecentNotes).toBe("function");
|
|
});
|
|
|
|
it("returns a component with css property", () => {
|
|
const component = RecentNotes();
|
|
expect(typeof component).toBe("function");
|
|
expect(typeof component.css).toBe("string");
|
|
});
|
|
});
|
|
|
|
describe("filterListedPages", () => {
|
|
it("excludes pages marked unlisted: true", () => {
|
|
const pages = [
|
|
{ slug: "a" },
|
|
{ slug: "b", unlisted: true },
|
|
{ slug: "c" },
|
|
{ slug: "d", unlisted: false },
|
|
];
|
|
const result = filterListedPages(pages);
|
|
expect(result.map((p) => p.slug)).toEqual(["a", "c", "d"]);
|
|
});
|
|
|
|
it("returns pages unchanged when none are unlisted", () => {
|
|
const pages = [{ slug: "a" }, { slug: "b" }];
|
|
expect(filterListedPages(pages)).toEqual(pages);
|
|
});
|
|
|
|
it("handles empty input", () => {
|
|
expect(filterListedPages([])).toEqual([]);
|
|
});
|
|
});
|