diff --git a/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts b/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts index 0c6c31feef..0e559fb6e9 100644 --- a/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts +++ b/src/sql/workbench/contrib/notebook/test/browser/notebookMarkdown.test.ts @@ -85,6 +85,13 @@ suite('NotebookMarkdownRenderer', () => { assert.strictEqual(result.innerHTML, `

test

`); }); + test('link to section in the same file', () => { + let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[#section](#section)`, isTrusted: true }); + assert.strictEqual(result.innerHTML, `

#section

`); + result = notebookMarkdownRenderer.renderMarkdown({ value: `section`, isTrusted: true }); + assert.strictEqual(result.innerHTML, `

section

`); + }); + test('cell attachment image', () => { let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `![altText](attachment:ads.png)`, isTrusted: true }, { cellAttachments: JSON.parse('{"ads.png":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAggg=="}}') }); assert.strictEqual(result.innerHTML, `

altText

`, 'Cell attachment basic test failed when trusted'); diff --git a/src/sql/workbench/contrib/notebook/test/calloutDialog/linkCalloutDialog.test.ts b/src/sql/workbench/contrib/notebook/test/calloutDialog/linkCalloutDialog.test.ts index a908331977..a68f756bd0 100644 --- a/src/sql/workbench/contrib/notebook/test/calloutDialog/linkCalloutDialog.test.ts +++ b/src/sql/workbench/contrib/notebook/test/calloutDialog/linkCalloutDialog.test.ts @@ -173,6 +173,28 @@ suite('Link Callout Dialog', function (): void { assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${sampleUrl})`, 'Markdown not returned correctly'); }); + test('Should return anchor link properly', async function (): Promise { + const defaultLabel = 'Link to section'; + const sampleUrl = '#section'; + let linkCalloutDialog = new LinkCalloutDialog('Title', 'below', defaultDialogProperties, defaultLabel, sampleUrl, + undefined, themeService, layoutService, telemetryService, contextKeyService, undefined, undefined, undefined); + linkCalloutDialog.render(); + + let deferred = new Deferred(); + // When I first open the callout dialog + linkCalloutDialog.open().then(value => { + deferred.resolve(value); + }); + linkCalloutDialog.url = sampleUrl; + + // And insert the dialog + linkCalloutDialog.insert(); + let result = await deferred.promise; + assert.strictEqual(result.insertUnescapedLinkLabel, defaultLabel, 'Label not returned correctly'); + assert.strictEqual(result.insertUnescapedLinkUrl, sampleUrl, 'Anchor link not returned correctly'); + assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${sampleUrl})`, 'Markdown not returned correctly'); + }); + test('Should handle quoted URLs properly', async function (): Promise { const defaultLabel = 'defaultLabel'; const unquotedUrl = 'C:/Test/Test.ipynb';