Remove the default date formatting
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { slugify, deriveSlug, deriveDate, postFilename } from "./slug";
|
||||
import { slugify, deriveSlug, deriveDate, pageFilename } from "./slug";
|
||||
|
||||
describe("slugify", () => {
|
||||
test("lowercases, drops apostrophes, hyphenates", () => {
|
||||
@@ -19,18 +19,18 @@ describe("deriveSlug", () => {
|
||||
describe("deriveDate", () => {
|
||||
const now = new Date("2026-06-19T12:00:00Z");
|
||||
test("uses frontmatter Date or string, else now", () => {
|
||||
expect(deriveDate({ frontmatterDate: new Date("2026-02-06T00:00:00Z"), now })).toBe("2026-02-06");
|
||||
expect(deriveDate({ frontmatterDate: "2026-02-18 09:00", now })).toBe("2026-02-18");
|
||||
expect(deriveDate({ now })).toBe("2026-06-19");
|
||||
expect(deriveDate({ frontmatterDate: new Date("2026-02-06T00:00:00Z"), })).toBe("2026-02-06");
|
||||
expect(deriveDate({ frontmatterDate: "2026-02-18 09:00" })).toBe("2026-02-18");
|
||||
expect(deriveDate({ frontmatterDate: "unparsable" })).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("postFilename", () => {
|
||||
test("joins date and slug", () => {
|
||||
expect(postFilename({ date: "2026-06-19", slug: "hello" })).toBe("2026-06-19-hello.md");
|
||||
expect(pageFilename({ date: "2026-06-19", slug: "hello" })).toBe("2026-06-19-hello.md");
|
||||
});
|
||||
|
||||
test("renders correctly without date", () => {
|
||||
expect(postFilename({ slug: "hello-without-date" })).toBe("hello-without-date.md");
|
||||
expect(pageFilename({ slug: "hello-without-date" })).toBe("hello-without-date.md");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user