honkit
Version:
HonKit is building beautiful books using Markdown.
82 lines (81 loc) • 2.44 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const bin_1 = require("../bin");
const path_1 = __importDefault(require("path"));
const jest_mock_process_1 = require("jest-mock-process");
const jest_serializer_strip_ansi_1 = require("@relmify/jest-serializer-strip-ansi");
const CWD = process.cwd();
const cwdPlugin = {
test: (value) => typeof value === "string" && value.includes(CWD),
print: (value, serialize) => {
if (typeof value === "string") {
return serialize(value.split(CWD).join("<CWD>").replace(/\\/g, "/"));
}
return value;
},
};
expect.addSnapshotSerializer(jest_serializer_strip_ansi_1.stripAnsi);
expect.addSnapshotSerializer(cwdPlugin);
describe("e2e", function () {
let stdoutMock;
beforeEach(() => {
stdoutMock = (0, jest_mock_process_1.mockProcessStdout)();
});
afterEach(() => {
stdoutMock.mockRestore();
});
it("`honkit parse` for multilang", async () => {
await (0, bin_1.run)([process.argv[0], "honkit", "parse", path_1.default.join(__dirname, "__fixtures__/multilang")]);
expect(stdoutMock.mock.calls).toMatchInlineSnapshot(`
[
[
"info: parsing multilingual book, with 2 languages
",
],
[
"warn: no summary file in this book
",
],
[
"warn: no summary file in this book
",
],
[
"info: Book located in: <CWD>/src/__tests__/__fixtures__/multilang
",
],
[
"info: 2 languages
",
],
[
"info: Language: English
",
],
[
"info: Introduction file is README.md
",
],
[
"info:
",
],
[
"info: Language: Japanese
",
],
[
"info: Introduction file is README.md
",
],
[
"info:
",
],
]
`);
});
});