mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Add additional notebook tests for handling relative links. (#17739)
This commit is contained in:
@@ -61,6 +61,9 @@ suite('Noteboook Link Handler', function (): void {
|
|||||||
|
|
||||||
result = new NotebookLinkHandler(notebookUri, Object.assign(document.createElement('a'), { href: '/tmp/inner/stuff.png' }), configurationService);
|
result = new NotebookLinkHandler(notebookUri, Object.assign(document.createElement('a'), { href: '/tmp/inner/stuff.png' }), configurationService);
|
||||||
assert.strictEqual(result.getLinkUrl(), `.${path.sep}inner${path.sep}stuff.png`, 'Basic link test below folder failed');
|
assert.strictEqual(result.getLinkUrl(), `.${path.sep}inner${path.sep}stuff.png`, 'Basic link test below folder failed');
|
||||||
|
|
||||||
|
result = new NotebookLinkHandler(notebookUri, Object.assign(document.createElement('a'), { href: '/other/stuff.png' }), configurationService);
|
||||||
|
assert.strictEqual(result.getLinkUrl(), `..${path.sep}other${path.sep}stuff.png`, 'Basic link test in different above folder failed');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Should return anchor links', () => {
|
test('Should return anchor links', () => {
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ suite('Link Callout Dialog', function (): void {
|
|||||||
assert.strictEqual(unquoteText(undefined), undefined);
|
assert.strictEqual(unquoteText(undefined), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Should return file link properly', async function (): Promise<void> {
|
test('Should return absolute file link properly', async function (): Promise<void> {
|
||||||
const defaultLabel = 'defaultLabel';
|
const defaultLabel = 'defaultLabel';
|
||||||
const sampleUrl = 'C:/Test/Test.ipynb';
|
const sampleUrl = 'C:/Test/Test.ipynb';
|
||||||
let linkCalloutDialog = new LinkCalloutDialog('Title', 'below', defaultDialogProperties, defaultLabel, sampleUrl,
|
let linkCalloutDialog = new LinkCalloutDialog('Title', 'below', defaultDialogProperties, defaultLabel, sampleUrl,
|
||||||
@@ -146,6 +146,28 @@ suite('Link Callout Dialog', function (): void {
|
|||||||
assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${sampleUrl})`, 'Markdown not returned correctly');
|
assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${sampleUrl})`, 'Markdown not returned correctly');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Should return relative file link properly', async function (): Promise<void> {
|
||||||
|
const defaultLabel = 'defaultLabel';
|
||||||
|
const sampleUrl = '../../Test.ipynb';
|
||||||
|
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, 'URL not returned correctly');
|
||||||
|
assert.strictEqual(result.insertEscapedMarkdown, `[${defaultLabel}](${sampleUrl})`, 'Markdown not returned correctly');
|
||||||
|
});
|
||||||
|
|
||||||
test('Should handle quoted URLs properly', async function (): Promise<void> {
|
test('Should handle quoted URLs properly', async function (): Promise<void> {
|
||||||
const defaultLabel = 'defaultLabel';
|
const defaultLabel = 'defaultLabel';
|
||||||
const unquotedUrl = 'C:/Test/Test.ipynb';
|
const unquotedUrl = 'C:/Test/Test.ipynb';
|
||||||
|
|||||||
Reference in New Issue
Block a user