UNPKG

honkit

Version:

HonKit is building beautiful books using Markdown.

30 lines (29 loc) 1.42 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const html_1 = require("@honkit/html"); const tmpdir_1 = require("../../../fs/tmpdir"); const svgToImg_1 = __importDefault(require("../svgToImg")); describe("svgToImg", () => { let dir; beforeEach(() => { dir = (0, tmpdir_1.createTmpDirWithRealPath)("honkit-svg-to-img-test-"); }); test("should write svg as a file", () => { const $ = (0, html_1.loadHtml)('<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.1"><rect width="200" height="100" stroke="black" stroke-width="6" fill="green"/></svg>'); return (0, svgToImg_1.default)(dir, "index.html", $).then(() => { const $img = $("img"); const src = $img.attr("src"); expect(dir).toHaveFile(src); }); }); it("should not write icon svg as a file", () => { const $ = (0, html_1.loadHtml)('<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.1" fill="currentColor"><rect width="200" height="100" stroke-width="6"/></svg>'); return (0, svgToImg_1.default)(dir, "index.html", $).then(() => { // @ts-expect-error expect($.contains("img")).toBe(false); }); }); });