@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
47 lines • 2.53 kB
JavaScript
;
// *****************************************************************************
// Copyright (C) 2026 EclipseSource and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const markdown_string_1 = require("./markdown-string");
describe('MarkdownStringImpl#appendCodeblock', () => {
it('uses a triple-backtick fence for code without backticks', () => {
const md = new markdown_string_1.MarkdownStringImpl();
md.appendCodeblock('json', '{ "type": "adaptive" }');
(0, chai_1.expect)(md.value).to.equal('\n```json\n{ "type": "adaptive" }\n```\n');
});
it('uses a longer fence when the code contains a triple-backtick run', () => {
const md = new markdown_string_1.MarkdownStringImpl();
const code = 'before\n```json\n{ "x": 1 }\n```\nafter';
md.appendCodeblock('', code);
// The fence must be at least 4 backticks so the inner ``` cannot close it.
(0, chai_1.expect)(md.value).to.equal('\n````\n' + code + '\n````\n');
});
it('grows the fence to be longer than the longest backtick run inside the code', () => {
const md = new markdown_string_1.MarkdownStringImpl();
const code = 'a ```` b ``` c';
md.appendCodeblock('', code);
// Longest run is 4, so fence must be 5.
(0, chai_1.expect)(md.value).to.equal('\n`````\n' + code + '\n`````\n');
});
it('still uses a triple-backtick fence when only single/double backticks appear', () => {
const md = new markdown_string_1.MarkdownStringImpl();
const code = 'inline `code` and ``double`` only';
md.appendCodeblock('', code);
(0, chai_1.expect)(md.value).to.equal('\n```\n' + code + '\n```\n');
});
});
//# sourceMappingURL=markdown-string.spec.js.map