mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 17:23:45 -05:00
add tests for anchor links (#19659)
This commit is contained in:
@@ -85,6 +85,13 @@ suite('NotebookMarkdownRenderer', () => {
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="https://www.test.com?test=&test2=" data-href="https://www.test.com?test=&test2=" title="https://www.test.com?test=&test2=" is-markdown="true" is-absolute="false">test</a></p>`);
|
||||
});
|
||||
|
||||
test('link to section in the same file', () => {
|
||||
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: `[#section](#section)`, isTrusted: true });
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="#section" data-href="#section" title="#section" is-markdown="true" is-absolute="false">#section</a></p>`);
|
||||
result = notebookMarkdownRenderer.renderMarkdown({ value: `<a href="#section">section</a>`, isTrusted: true });
|
||||
assert.strictEqual(result.innerHTML, `<p><a href="#section">section</a></p>`);
|
||||
});
|
||||
|
||||
test('cell attachment image', () => {
|
||||
let result: HTMLElement = notebookMarkdownRenderer.renderMarkdown({ value: ``, isTrusted: true }, { cellAttachments: JSON.parse('{"ads.png":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAggg=="}}') });
|
||||
assert.strictEqual(result.innerHTML, `<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAggg==" alt="altText"></p>`, 'Cell attachment basic test failed when trusted');
|
||||
|
||||
@@ -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<void> {
|
||||
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<ILinkCalloutDialogOptions>();
|
||||
// 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<void> {
|
||||
const defaultLabel = 'defaultLabel';
|
||||
const unquotedUrl = 'C:/Test/Test.ipynb';
|
||||
|
||||
Reference in New Issue
Block a user