test: compare emitted paths with / and give the parser POSIX paths, so the new tests pass on Windows

This commit is contained in:
saberzero1 committed 2026-11-27 16:32:34 +01:00
1 parent 74d06afca0
commit c03c643a7c
3 files changed
+8 -6

No files matched your search

@@ -106,7 +106,7 @@ async function emit(
} as unknown as BuildCtx
const written: string[] = []
for await (const fp of ComponentResources().emit(ctx, [], resources) as AsyncIterable<string>) {
written.push(path.relative(output, fp))
written.push(path.relative(output, fp).split(path.sep).join("/"))
}
const read = (name: string) => fs.readFileSync(path.join(output, name), "utf8")
return { ctx, written, read }
@@ -104,7 +104,7 @@ const linkOf = ([tree]: ReturnType<typeof page>) => (tree as Root).children[0] a
async function collect(gen: AsyncGenerator<FilePath> | AsyncIterable<FilePath>, output: string) {
const out: string[] = []
for await (const fp of gen) out.push(path.relative(output, fp))
for await (const fp of gen) out.push(path.relative(output, fp).split(path.sep).join("/"))
return out.sort()
}
+6 -4
View File
@@ -68,11 +68,13 @@ describe("parseMarkdown (one thread)", () => {
})
test("runs text, Markdown and HTML transforms in plugin order and sets the file's paths", async () => {
const dir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "quartz-parse-"))
// Quartz passes POSIX-style paths (its glob yields them on Windows too)
const posix = (p: string) => p.split(path.sep).join("/")
const dir = posix(await fs.promises.mkdtemp(path.join(os.tmpdir(), "quartz-parse-")))
try {
await fs.promises.mkdir(path.join(dir, "Sub Folder"))
const a = path.join(dir, "Sub Folder", "My Note.md")
const b = path.join(dir, "other.md")
await fs.promises.mkdir(`${dir}/Sub Folder`)
const a = `${dir}/Sub Folder/My Note.md`
const b = `${dir}/other.md`
await fs.promises.writeFile(a, "\n\n # Title \n\n")
await fs.promises.writeFile(b, "text")
const log: string[] = []