honkit
Version:
HonKit is building beautiful books using Markdown.
39 lines (38 loc) • 1.84 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const getOutputFolder_1 = __importDefault(require("../getOutputFolder"));
describe("getOutputFolder", () => {
// Use platform-appropriate absolute paths for testing
const bookRoot = path_1.default.resolve("/book/root");
const absoluteOutput = path_1.default.resolve("/absolute/output");
describe("relative output path", () => {
it("should resolve relative to book root", () => {
const result = (0, getOutputFolder_1.default)([bookRoot, "./output"]);
expect(result).toBe(path_1.default.join(bookRoot, "output"));
});
it("should resolve relative path without ./ prefix", () => {
const result = (0, getOutputFolder_1.default)([bookRoot, "dist"]);
expect(result).toBe(path_1.default.join(bookRoot, "dist"));
});
});
describe("absolute output path", () => {
it("should preserve absolute path as-is", () => {
const result = (0, getOutputFolder_1.default)([bookRoot, absoluteOutput]);
expect(result).toBe(absoluteOutput);
});
});
describe("default output folder", () => {
it("should use _book in book root when no output specified", () => {
const result = (0, getOutputFolder_1.default)([bookRoot]);
expect(result).toBe(path_1.default.join(bookRoot, "_book"));
});
it("should use _book in cwd when no args", () => {
const result = (0, getOutputFolder_1.default)([]);
expect(result).toBe(path_1.default.join(process.cwd(), "_book"));
});
});
});