dokkie
Version:
Create good looking documentation from your Readme
80 lines • 3.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const files_1 = require("../utils/files");
const mock_1 = require("../test/mock");
const input = {
ext: ".md",
path: "",
data: "",
name: "readme",
meta: {},
html: "",
};
describe("makeFileName", () => {
it("index", () => {
const altInput = Object.assign(Object.assign({}, input), { name: "readme" });
const output = "index.html";
// Assert
expect(expect(files_1.makeFileName(altInput)).toEqual(output));
});
it("sub", () => {
const altInput = Object.assign(Object.assign({}, input), { name: "test" });
const output = "test/index.html";
// Assert
expect(expect(files_1.makeFileName(altInput)).toEqual(output));
});
});
describe("makeRoute", () => {
it("to make a route", () => {
const altInput = Object.assign(Object.assign({}, input), { name: "test" });
const output = "/test/index.html";
// Assert
expect(expect(files_1.makeRoute(altInput, mock_1.baseSettings)).toEqual(output));
});
it("alternative input dir", () => {
const output = "/my/folder/readme/index.html";
const altInput = Object.assign(Object.assign({}, input), { name: "my/folder/readme" });
// Assert
expect(expect(files_1.makeRoute(altInput, mock_1.baseSettings)).toEqual(output));
});
it("alternative input dir - with strip", () => {
const output = "/my/readme/index.html";
const altInput = Object.assign(Object.assign({}, input), { name: "my/folder/readme" });
mock_1.baseSettings.strip = ["folder"];
// Assert
expect(expect(files_1.makeRoute(altInput, mock_1.baseSettings)).toEqual(output));
});
it("alternative input dir - with alternative input", () => {
const output = "/my/readme/index.html";
const altInput = Object.assign(Object.assign({}, input), { name: "my/folder/readme" });
mock_1.baseSettings.strip = [];
mock_1.baseSettings.input = "folder";
// Assert
expect(expect(files_1.makeRoute(altInput, mock_1.baseSettings)).toEqual(output));
});
});
describe("makePath", () => {
it("should make a path", () => {
const output = process.cwd() + "/dokkie";
expect(expect(files_1.makePath(input, mock_1.baseSettings)).toEqual(output));
});
});
describe("getPageTitle", () => {
// Assert
it("with meta, Should find the title in the metadata", () => {
const altInput = Object.assign(Object.assign({}, input), { meta: { title: "test-meta" } });
const output = "test-meta";
expect(files_1.getPageTitle(altInput)).toEqual(output);
});
it("without meta - with title in file, Should use the title of the first h1 in the content", () => {
const altInput = Object.assign(Object.assign({}, input), { data: `# test-file` });
const output = "test-file";
expect(files_1.getPageTitle(altInput)).toEqual(output);
});
it("without meta or title - Should use the filename as a title", () => {
const altInput = Object.assign({}, input);
const output = "readme";
expect(files_1.getPageTitle(altInput)).toEqual(output);
});
});
//# sourceMappingURL=files.spec.js.map