/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; import * as marked from 'vs/base/common/marked/marked'; import { renderMarkdown } from 'vs/base/browser/markdownRenderer'; import { MarkdownString } from 'vs/base/common/htmlContent'; suite('MarkdownRenderer', () => { suite('Images', () => { test('image rendering conforms to default', () => { const markdown = { value: `` }; const result: HTMLElement = renderMarkdown(markdown); const renderer = new marked.Renderer(); const imageFromMarked = marked(markdown.value, { sanitize: true, renderer }).trim(); assert.strictEqual(result.innerHTML, imageFromMarked); }); test('image rendering conforms to default without title', () => { const markdown = { value: `` }; const result: HTMLElement = renderMarkdown(markdown); const renderer = new marked.Renderer(); const imageFromMarked = marked(markdown.value, { sanitize: true, renderer }).trim(); assert.strictEqual(result.innerHTML, imageFromMarked); }); test('image width from title params', () => { let result: HTMLElement = renderMarkdown({ value: `` }); assert.strictEqual(result.innerHTML, `
$(zap) $(not a theme icon) $(add)
`); }); test('render appendMarkdown', () => { const mds = new MarkdownString(undefined, { supportThemeIcons: true }); mds.appendMarkdown('$(zap) $(not a theme icon) $(add)'); let result: HTMLElement = renderMarkdown(mds); assert.strictEqual(result.innerHTML, `$(not a theme icon)
`); }); test('render appendMarkdown with escaped icon', () => { const mds = new MarkdownString(undefined, { supportThemeIcons: true }); mds.appendMarkdown('\\$(zap) $(not a theme icon) $(add)'); let result: HTMLElement = renderMarkdown(mds); assert.strictEqual(result.innerHTML, `$(zap) $(not a theme icon)
`); }); }); suite('ThemeIcons Support Off', () => { test('render appendText', () => { const mds = new MarkdownString(undefined, { supportThemeIcons: false }); mds.appendText('$(zap) $(not a theme icon) $(add)'); let result: HTMLElement = renderMarkdown(mds); assert.strictEqual(result.innerHTML, `$(zap) $(not a theme icon) $(add)
`); }); test('render appendMarkdown with escaped icon', () => { const mds = new MarkdownString(undefined, { supportThemeIcons: false }); mds.appendMarkdown('\\$(zap) $(not a theme icon) $(add)'); let result: HTMLElement = renderMarkdown(mds); assert.strictEqual(result.innerHTML, `$(zap) $(not a theme icon) $(add)
`); }); }); });