Fix potentiall undefined ref

This commit is contained in:
Matt Bierner
2018-01-12 14:12:52 -08:00
parent e932b8ad9c
commit 519b4723d5
2 changed files with 33 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ import * as vscode from 'vscode';
import { createRandomFile, deleteFile, closeAllEditors, pathEquals } from './utils';
import { join, basename } from 'path';
import * as fs from 'fs';
import { Uri } from 'vscode';
suite('workspace-namespace', () => {
@@ -510,7 +511,7 @@ suite('workspace-namespace', () => {
test('applyEdit should fail when editing deleted resource', async () => {
const resource = await createRandomFile();
let edit = new vscode.WorkspaceEdit();
const edit = new vscode.WorkspaceEdit();
edit.deleteResource(resource);
try {
edit.insert(resource, new vscode.Position(0, 0), '');
@@ -519,4 +520,30 @@ suite('workspace-namespace', () => {
// noop
}
});
test('applyEdit should fail when renaming deleted resource', async () => {
const resource = await createRandomFile();
const edit = new vscode.WorkspaceEdit();
edit.deleteResource(resource);
try {
edit.renameResource(resource, resource);
assert.fail(false, 'Should disallow rename of deleted resource');
} catch {
// noop
}
});
test('applyEdit should fail when editing renamed from resource', async () => {
const resource = await createRandomFile();
const newResource = Uri.parse(resource.fsPath + '.1');
const edit = new vscode.WorkspaceEdit();
edit.renameResource(resource, newResource);
try {
edit.insert(resource, new vscode.Position(0, 0), '');
assert.fail(false, 'Should disallow editing renamed file');
} catch {
// noop
}
});
});