UNPKG

honkit

Version:

HonKit is building beautiful books using Markdown.

67 lines (66 loc) 2.4 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const immutable_1 = __importDefault(require("immutable")); const summary_1 = __importDefault(require("../../../models/summary")); const file_1 = __importDefault(require("../../../models/file")); const moveArticle_1 = __importDefault(require("../moveArticle")); describe("moveArticle", () => { const summary = summary_1.default.createFromParts(new file_1.default(), [ { articles: [ { title: "1.1", path: "1.1", }, { title: "1.2", path: "1.2", }, ], }, { title: "Part I", articles: [ { title: "2.1", path: "2.1", articles: [ { title: "2.1.1", path: "2.1.1", }, { title: "2.1.2", path: "2.1.2", }, ], }, { title: "2.2", path: "2.2", }, ], }, ]); test("should move an article to the same place", () => { const newSummary = (0, moveArticle_1.default)(summary, "2.1", "2.1"); expect(immutable_1.default.is(summary, newSummary)).toBe(true); }); test("should move an article to an previous level", () => { const newSummary = (0, moveArticle_1.default)(summary, "2.2", "2.1"); const moved = newSummary.getByLevel("2.1"); const other = newSummary.getByLevel("2.2"); expect(moved.getTitle()).toBe("2.2"); expect(other.getTitle()).toBe("2.1"); }); test("should move an article to a next level", () => { const newSummary = (0, moveArticle_1.default)(summary, "2.1", "2.2"); const moved = newSummary.getByLevel("2.1"); const other = newSummary.getByLevel("2.2"); expect(moved.getTitle()).toBe("2.2"); expect(other.getTitle()).toBe("2.1"); }); });