|
1 | 1 | import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
2 | 2 | import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
3 | 3 | import { tmpdir } from "node:os"; |
4 | | -import { basename, join, resolve } from "node:path"; |
| 4 | +import { basename, dirname, join, parse, resolve } from "node:path"; |
5 | 5 | import { CliUsageError } from "../../utils/commandResult.js"; |
6 | 6 | import { createRenderPlan } from "./plan.js"; |
7 | 7 |
|
@@ -196,10 +196,17 @@ describe("createRenderPlan", () => { |
196 | 196 | expect(plan.format).toBe("hls"); |
197 | 197 | expect(plan.hlsSegmentSeconds).toBe(4); |
198 | 198 | // No extension: outputPath is the directory the playlists are written into. |
199 | | - expect(plan.outputPath.startsWith(resolve("renders", plan.project.name))).toBe(true); |
| 199 | + expect(plan.outputPath.startsWith(join(projectDir, "renders", plan.project.name))).toBe(true); |
200 | 200 | expect(basename(plan.outputPath)).not.toContain("."); |
201 | 201 | }); |
202 | 202 |
|
| 203 | + it("writes the default output under the project's renders folder whatever the cwd is", () => { |
| 204 | + vi.spyOn(process, "cwd").mockReturnValue(parse(projectDir).root); |
| 205 | + const plan = createRenderPlan({ dir: projectDir }); |
| 206 | + |
| 207 | + expect(dirname(plan.outputPath)).toBe(join(projectDir, "renders")); |
| 208 | + }); |
| 209 | + |
203 | 210 | it("carries an explicit --hls-segment-seconds and rejects a fractional one", () => { |
204 | 211 | expect( |
205 | 212 | createRenderPlan({ dir: projectDir, format: "hls", "hls-segment-seconds": "6" }) |
|
0 commit comments