rm test for custom permarlink converter (irrelevant)
This commit is contained in:
@@ -25,35 +25,4 @@ describe("getPermalinks", () => {
|
|||||||
expect(expectedPermalinks).toContain(permalink);
|
expect(expectedPermalinks).toContain(permalink);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("should return an array of permalinks with custom path -> permalink converter function", () => {
|
|
||||||
const expectedPermalinks = [
|
|
||||||
"/", // /index.md
|
|
||||||
"/abc",
|
|
||||||
"/blog/first-post",
|
|
||||||
"/blog/second-post",
|
|
||||||
"/blog/third-post",
|
|
||||||
"/blog", // /blog/index.md
|
|
||||||
"/blog/tutorials/first-tutorial",
|
|
||||||
"/assets/pasted-image-123.png",
|
|
||||||
];
|
|
||||||
|
|
||||||
const func = (filePath: string, markdownFolder: string) => {
|
|
||||||
const permalink = filePath
|
|
||||||
.replace(markdownFolder, "") // make the permalink relative to the markdown folder
|
|
||||||
.replace(/\.(mdx|md)/, "")
|
|
||||||
.replace(/\\/g, "/") // replace windows backslash with forward slash
|
|
||||||
.replace(/\/index$/, "") // remove index from the end of the permalink
|
|
||||||
.replace(/ /g, "-") // replace spaces with hyphens
|
|
||||||
.toLowerCase(); // convert to lowercase
|
|
||||||
|
|
||||||
return permalink.length > 0 ? permalink : "/"; // for home page
|
|
||||||
};
|
|
||||||
|
|
||||||
const permalinks = getPermalinks(markdownFolder, [/\.DS_Store/], func);
|
|
||||||
expect(permalinks).toHaveLength(expectedPermalinks.length);
|
|
||||||
permalinks.forEach((permalink) => {
|
|
||||||
expect(expectedPermalinks).toContain(permalink);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user