UNPKG

mume-with-litvis

Version:

Fork of mume with added http://litvis.org/

60 lines 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const block_info_1 = require("../../src/lib/block-info"); const testCasesForParseBlockInfo = [ { info: { language: "js", attributes: { cmd: true } }, raw: [ "js cmd=true", "js {cmd=true}", "js { cmd=true } ", "js{cmd=True}", ], }, { info: { language: "hello", attributes: {} }, raw: ["hello", " hello ", "hello {}", "hello { }"], }, { info: { language: undefined, attributes: { just: "attribute" } }, raw: [" {just=attribute}"], }, ]; const testCasesForNormalizeCodeBlockInfo = [ { infos: [{}], normalizedInfo: { language: "", attributes: {} }, }, { infos: [ { language: "js", attributes: { cmd: true } }, { language: "js", attributes: { Cmd: true } }, { language: "js", attributes: { CMD: true } }, ], normalizedInfo: { language: "js", attributes: { cmd: true } }, }, { infos: [{ language: "vega" }, { language: "VEGA", attributes: {} }], normalizedInfo: { language: "vega", attributes: {} }, }, ]; describe("lib/block-info", () => { testCasesForParseBlockInfo.map(({ raw, info }) => { const arrayOfTexts = typeof raw === "string" ? [raw] : raw; arrayOfTexts.map((text) => { it(`parseBlockInfo() correctly parses ${text}`, () => { const result = block_info_1.parseBlockInfo(text); expect(result).toEqual(info); }); }); }); testCasesForNormalizeCodeBlockInfo.map(({ infos, normalizedInfo }) => { infos.map((info) => { it(`normalizeCodeBlockInfo() correctly normalizes ${JSON.stringify(info)}`, () => { const result = block_info_1.normalizeBlockInfo(info); expect(result).toEqual(normalizedInfo); }); }); }); }); //# sourceMappingURL=block-info.test.js.map