Add tests to NotebookUriHandler (#11959)

* NotebookUriHandler Test

* set test to previous, return promise for handleUri

* Added tests for file uri scheme https/http

* Updated NotebookUri to await handleUri calls and add more tests
This commit is contained in:
Vasu Bhog
2020-08-28 10:51:12 -05:00
committed by GitHub
parent 795300347b
commit d59063ebab
5 changed files with 145 additions and 7 deletions

View File

@@ -14,6 +14,8 @@ const localize = nls.loadMessageBundle();
import { IQuestion, confirm } from '../prompts/question';
import CodeAdapter from '../prompts/adapter';
import { getErrorMessage, isEditorTitleFree } from '../common/utils';
import * as constants from '../common/constants';
export class NotebookUriHandler implements vscode.UriHandler {
private prompter = new CodeAdapter();
@@ -24,24 +26,22 @@ export class NotebookUriHandler implements vscode.UriHandler {
handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
switch (uri.path) {
case '/new':
vscode.commands.executeCommand('notebook.command.new');
break;
return vscode.commands.executeCommand(constants.notebookCommandNew);
case '/open':
this.open(uri);
break;
return this.open(uri);
default:
vscode.window.showErrorMessage(localize('notebook.unsupportedAction', "Action {0} is not supported for this handler", uri.path));
}
}
private open(uri: vscode.Uri): void {
private open(uri: vscode.Uri): Promise<void> {
const data = querystring.parse(uri.query);
if (!data.url) {
console.warn('Failed to open URI:', uri);
}
this.openNotebook(data.url);
return this.openNotebook(data.url);
}
private async openNotebook(url: string | string[]): Promise<void> {