mirror of
https://github.com/microsoft/vscode.git
synced 2026-06-05 23:26:27 +01:00
Strict null supressions in test files
This commit is contained in:
+27
-28
@@ -19,7 +19,7 @@ import { CancellationToken } from 'vscode';
|
||||
import * as Types from 'vs/base/common/types';
|
||||
|
||||
suite('Configuration Resolver Service', () => {
|
||||
let configurationResolverService: IConfigurationResolverService;
|
||||
let configurationResolverService: IConfigurationResolverService | null;
|
||||
let envVariables: { [key: string]: string } = { key1: 'Value for key1', key2: 'Value for key2' };
|
||||
let mockCommandService: MockCommandService;
|
||||
let editorService: TestEditorService;
|
||||
@@ -45,46 +45,46 @@ suite('Configuration Resolver Service', () => {
|
||||
|
||||
test('substitute one', () => {
|
||||
if (platform.isWindows) {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, 'abc ${workspaceFolder} xyz'), 'abc \\VSCode\\workspaceLocation xyz');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, 'abc ${workspaceFolder} xyz'), 'abc \\VSCode\\workspaceLocation xyz');
|
||||
} else {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, 'abc ${workspaceFolder} xyz'), 'abc /VSCode/workspaceLocation xyz');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, 'abc ${workspaceFolder} xyz'), 'abc /VSCode/workspaceLocation xyz');
|
||||
}
|
||||
});
|
||||
|
||||
test('workspace root folder name', () => {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, 'abc ${workspaceRootFolderName} xyz'), 'abc workspaceLocation xyz');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, 'abc ${workspaceRootFolderName} xyz'), 'abc workspaceLocation xyz');
|
||||
});
|
||||
|
||||
// TODO@isidor mock the editor service properly
|
||||
// test('current selected line number', () => {
|
||||
// assert.strictEqual(configurationResolverService.resolve(workspace, 'abc ${lineNumber} xyz'), `abc ${editorService.mockLineNumber} xyz`);
|
||||
// assert.strictEqual(configurationResolverService!.resolve(workspace, 'abc ${lineNumber} xyz'), `abc ${editorService.mockLineNumber} xyz`);
|
||||
// });
|
||||
|
||||
// test('current selected text', () => {
|
||||
// assert.strictEqual(configurationResolverService.resolve(workspace, 'abc ${selectedText} xyz'), `abc ${editorService.mockSelectedText} xyz`);
|
||||
// assert.strictEqual(configurationResolverService!.resolve(workspace, 'abc ${selectedText} xyz'), `abc ${editorService.mockSelectedText} xyz`);
|
||||
// });
|
||||
|
||||
test('substitute many', () => {
|
||||
if (platform.isWindows) {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, '${workspaceFolder} - ${workspaceFolder}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, '${workspaceFolder} - ${workspaceFolder}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation');
|
||||
} else {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, '${workspaceFolder} - ${workspaceFolder}'), '/VSCode/workspaceLocation - /VSCode/workspaceLocation');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, '${workspaceFolder} - ${workspaceFolder}'), '/VSCode/workspaceLocation - /VSCode/workspaceLocation');
|
||||
}
|
||||
});
|
||||
|
||||
test('substitute one env variable', () => {
|
||||
if (platform.isWindows) {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, 'abc ${workspaceFolder} ${env:key1} xyz'), 'abc \\VSCode\\workspaceLocation Value for key1 xyz');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, 'abc ${workspaceFolder} ${env:key1} xyz'), 'abc \\VSCode\\workspaceLocation Value for key1 xyz');
|
||||
} else {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, 'abc ${workspaceFolder} ${env:key1} xyz'), 'abc /VSCode/workspaceLocation Value for key1 xyz');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, 'abc ${workspaceFolder} ${env:key1} xyz'), 'abc /VSCode/workspaceLocation Value for key1 xyz');
|
||||
}
|
||||
});
|
||||
|
||||
test('substitute many env variable', () => {
|
||||
if (platform.isWindows) {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, '${workspaceFolder} - ${workspaceFolder} ${env:key1} - ${env:key2}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for key1 - Value for key2');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, '${workspaceFolder} - ${workspaceFolder} ${env:key1} - ${env:key2}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation Value for key1 - Value for key2');
|
||||
} else {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, '${workspaceFolder} - ${workspaceFolder} ${env:key1} - ${env:key2}'), '/VSCode/workspaceLocation - /VSCode/workspaceLocation Value for key1 - Value for key2');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, '${workspaceFolder} - ${workspaceFolder} ${env:key1} - ${env:key2}'), '/VSCode/workspaceLocation - /VSCode/workspaceLocation Value for key1 - Value for key2');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ suite('Configuration Resolver Service', () => {
|
||||
// '${workspaceRootFolderName}': '${lineNumber}',
|
||||
// 'hey ${env:key1} ': '${workspaceRootFolderName}'
|
||||
// };
|
||||
// assert.deepEqual(configurationResolverService.resolve(workspace, myObject), {
|
||||
// assert.deepEqual(configurationResolverService!.resolve(workspace, myObject), {
|
||||
// 'workspaceLocation': `${editorService.mockLineNumber}`,
|
||||
// 'hey Value for key1 ': 'workspaceLocation'
|
||||
// });
|
||||
@@ -102,15 +102,14 @@ suite('Configuration Resolver Service', () => {
|
||||
|
||||
test('substitute one env variable using platform case sensitivity', () => {
|
||||
if (platform.isWindows) {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, '${env:key1} - ${env:Key1}'), 'Value for key1 - Value for key1');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, '${env:key1} - ${env:Key1}'), 'Value for key1 - Value for key1');
|
||||
} else {
|
||||
assert.strictEqual(configurationResolverService.resolve(workspace, '${env:key1} - ${env:Key1}'), 'Value for key1 - ');
|
||||
assert.strictEqual(configurationResolverService!.resolve(workspace, '${env:key1} - ${env:Key1}'), 'Value for key1 - ');
|
||||
}
|
||||
});
|
||||
|
||||
test('substitute one configuration variable', () => {
|
||||
let configurationService: IConfigurationService;
|
||||
configurationService = new MockConfigurationService({
|
||||
let configurationService: IConfigurationService = new MockConfigurationService({
|
||||
editor: {
|
||||
fontFamily: 'foo'
|
||||
},
|
||||
@@ -256,7 +255,7 @@ suite('Configuration Resolver Service', () => {
|
||||
'outDir': null
|
||||
};
|
||||
|
||||
return configurationResolverService.resolveWithInteractionReplace(undefined, configuration).then(result => {
|
||||
return configurationResolverService!.resolveWithInteractionReplace(undefined, configuration).then(result => {
|
||||
|
||||
assert.deepEqual(result, {
|
||||
'name': 'Attach to Process',
|
||||
@@ -285,7 +284,7 @@ suite('Configuration Resolver Service', () => {
|
||||
const commandVariables = Object.create(null);
|
||||
commandVariables['commandVariable1'] = 'command1';
|
||||
|
||||
return configurationResolverService.resolveWithInteractionReplace(undefined, configuration, undefined, commandVariables).then(result => {
|
||||
return configurationResolverService!.resolveWithInteractionReplace(undefined, configuration, undefined, commandVariables).then(result => {
|
||||
|
||||
assert.deepEqual(result, {
|
||||
'name': 'Attach to Process',
|
||||
@@ -318,7 +317,7 @@ suite('Configuration Resolver Service', () => {
|
||||
const commandVariables = Object.create(null);
|
||||
commandVariables['commandVariable1'] = 'command1';
|
||||
|
||||
return configurationResolverService.resolveWithInteractionReplace(undefined, configuration, undefined, commandVariables).then(result => {
|
||||
return configurationResolverService!.resolveWithInteractionReplace(undefined, configuration, undefined, commandVariables).then(result => {
|
||||
|
||||
assert.deepEqual(result, {
|
||||
'name': 'Attach to Process',
|
||||
@@ -349,7 +348,7 @@ suite('Configuration Resolver Service', () => {
|
||||
const commandVariables = Object.create(null);
|
||||
commandVariables['commandVariable1'] = 'command1';
|
||||
|
||||
return configurationResolverService.resolveWithInteractionReplace(undefined, configuration, undefined, commandVariables).then(result => {
|
||||
return configurationResolverService!.resolveWithInteractionReplace(undefined, configuration, undefined, commandVariables).then(result => {
|
||||
|
||||
assert.deepEqual(result, {
|
||||
'name': 'Attach to Process',
|
||||
@@ -374,7 +373,7 @@ suite('Configuration Resolver Service', () => {
|
||||
'outDir': null
|
||||
};
|
||||
|
||||
return configurationResolverService.resolveWithInteractionReplace(workspace, configuration, 'tasks').then(result => {
|
||||
return configurationResolverService!.resolveWithInteractionReplace(workspace, configuration, 'tasks').then(result => {
|
||||
|
||||
assert.deepEqual(result, {
|
||||
'name': 'Attach to Process',
|
||||
@@ -401,7 +400,7 @@ suite('Configuration Resolver Service', () => {
|
||||
'outDir': null
|
||||
};
|
||||
|
||||
return configurationResolverService.resolveWithInteractionReplace(workspace, configuration, 'tasks').then(result => {
|
||||
return configurationResolverService!.resolveWithInteractionReplace(workspace, configuration, 'tasks').then(result => {
|
||||
|
||||
assert.deepEqual(result, {
|
||||
'name': 'Attach to Process',
|
||||
@@ -428,7 +427,7 @@ suite('Configuration Resolver Service', () => {
|
||||
'outDir': null
|
||||
};
|
||||
|
||||
return configurationResolverService.resolveWithInteractionReplace(workspace, configuration, 'tasks').then(result => {
|
||||
return configurationResolverService!.resolveWithInteractionReplace(workspace, configuration, 'tasks').then(result => {
|
||||
|
||||
assert.deepEqual(result, {
|
||||
'name': 'Attach to Process',
|
||||
@@ -456,7 +455,7 @@ suite('Configuration Resolver Service', () => {
|
||||
'outDir': null
|
||||
};
|
||||
|
||||
return configurationResolverService.resolveWithInteractionReplace(workspace, configuration, 'tasks').then(result => {
|
||||
return configurationResolverService!.resolveWithInteractionReplace(workspace, configuration, 'tasks').then(result => {
|
||||
|
||||
assert.deepEqual(result, {
|
||||
'name': 'resolvedEnterinput3',
|
||||
@@ -490,15 +489,15 @@ class MockConfigurationService implements IConfigurationService {
|
||||
const valuePath = (<string>value).split('.');
|
||||
let object = this.configuration;
|
||||
while (valuePath.length && object) {
|
||||
object = object[valuePath.shift()];
|
||||
object = object[valuePath.shift()!];
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
public updateValue(): Promise<void> { return null; }
|
||||
public updateValue(): Promise<void> { return Promise.resolve(); }
|
||||
public getConfigurationData(): any { return null; }
|
||||
public onDidChangeConfiguration() { return { dispose() { } }; }
|
||||
public reloadConfiguration() { return null; }
|
||||
public reloadConfiguration() { return Promise.resolve(); }
|
||||
}
|
||||
|
||||
class MockCommandService implements ICommandService {
|
||||
|
||||
@@ -41,7 +41,7 @@ export class TestEditorInput extends EditorInput implements IFileEditorInput {
|
||||
constructor(private resource: URI) { super(); }
|
||||
|
||||
getTypeId() { return 'testEditorInputForEditorGroupService'; }
|
||||
resolve(): Promise<IEditorModel> { return Promise.resolve(undefined); }
|
||||
resolve(): Promise<IEditorModel | null> { return Promise.resolve(null); }
|
||||
matches(other: TestEditorInput): boolean { return other && this.resource.toString() === other.resource.toString() && other instanceof TestEditorInput; }
|
||||
setEncoding(encoding: string) { }
|
||||
getEncoding(): string { return null!; }
|
||||
|
||||
@@ -120,7 +120,7 @@ suite('Editor service', () => {
|
||||
assert.equal(visibleEditorChangeEventCounter, 1);
|
||||
|
||||
// Close input
|
||||
return editor.group.closeEditor(input).then(() => {
|
||||
return editor.group!.closeEditor(input).then(() => {
|
||||
assert.equal(didCloseEditorListenerCounter, 1);
|
||||
assert.equal(activeEditorChangeEventCounter, 2);
|
||||
assert.equal(visibleEditorChangeEventCounter, 2);
|
||||
@@ -260,7 +260,7 @@ suite('Editor service', () => {
|
||||
class MyEditor extends BaseEditor {
|
||||
|
||||
constructor(id: string) {
|
||||
super(id, null, new TestThemeService(), new TestStorageService());
|
||||
super(id, undefined, new TestThemeService(), new TestStorageService());
|
||||
}
|
||||
|
||||
getId(): string {
|
||||
@@ -403,7 +403,7 @@ suite('Editor service', () => {
|
||||
|
||||
// 1.) open, open same, open other, close
|
||||
let editor = await service.openEditor(input, { pinned: true });
|
||||
const group = editor.group;
|
||||
const group = editor.group!;
|
||||
assertActiveEditorChangedEvent(true);
|
||||
assertVisibleEditorsChangedEvent(true);
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ suite('Files - TextFileEditorModel', () => {
|
||||
|
||||
model.onDidStateChange(e => {
|
||||
if (e === StateChange.SAVED) {
|
||||
assert.equal(snapshotToString(model.createSnapshot()), 'bar');
|
||||
assert.equal(snapshotToString(model.createSnapshot()!), 'bar');
|
||||
assert.ok(!model.isDirty());
|
||||
eventCounter++;
|
||||
}
|
||||
@@ -337,7 +337,7 @@ suite('Files - TextFileEditorModel', () => {
|
||||
assert.ok(!sequentializer.pendingSave);
|
||||
|
||||
// pending removes itself after done
|
||||
return sequentializer.setPending(1, Promise.resolve(null)).then(() => {
|
||||
return sequentializer.setPending(1, Promise.resolve()).then(() => {
|
||||
assert.ok(!sequentializer.hasPendingSave());
|
||||
assert.ok(!sequentializer.hasPendingSave(1));
|
||||
assert.ok(!sequentializer.pendingSave);
|
||||
@@ -361,11 +361,11 @@ suite('Files - TextFileEditorModel', () => {
|
||||
const sequentializer = new SaveSequentializer();
|
||||
|
||||
let pendingDone = false;
|
||||
sequentializer.setPending(1, timeout(1).then(() => { pendingDone = true; return null; }));
|
||||
sequentializer.setPending(1, timeout(1).then(() => { pendingDone = true; return; }));
|
||||
|
||||
// next finishes instantly
|
||||
let nextDone = false;
|
||||
const res = sequentializer.setNext(() => Promise.resolve(null).then(() => { nextDone = true; return null; }));
|
||||
const res = sequentializer.setNext(() => Promise.resolve(null).then(() => { nextDone = true; return; }));
|
||||
|
||||
return res.then(() => {
|
||||
assert.ok(pendingDone);
|
||||
@@ -377,11 +377,11 @@ suite('Files - TextFileEditorModel', () => {
|
||||
const sequentializer = new SaveSequentializer();
|
||||
|
||||
let pendingDone = false;
|
||||
sequentializer.setPending(1, timeout(1).then(() => { pendingDone = true; return null; }));
|
||||
sequentializer.setPending(1, timeout(1).then(() => { pendingDone = true; return; }));
|
||||
|
||||
// next finishes after timeout
|
||||
let nextDone = false;
|
||||
const res = sequentializer.setNext(() => timeout(1).then(() => { nextDone = true; return null; }));
|
||||
const res = sequentializer.setNext(() => timeout(1).then(() => { nextDone = true; return; }));
|
||||
|
||||
return res.then(() => {
|
||||
assert.ok(pendingDone);
|
||||
@@ -393,17 +393,17 @@ suite('Files - TextFileEditorModel', () => {
|
||||
const sequentializer = new SaveSequentializer();
|
||||
|
||||
let pendingDone = false;
|
||||
sequentializer.setPending(1, timeout(1).then(() => { pendingDone = true; return null; }));
|
||||
sequentializer.setPending(1, timeout(1).then(() => { pendingDone = true; return; }));
|
||||
|
||||
// next finishes after timeout
|
||||
let firstDone = false;
|
||||
let firstRes = sequentializer.setNext(() => timeout(2).then(() => { firstDone = true; return null; }));
|
||||
let firstRes = sequentializer.setNext(() => timeout(2).then(() => { firstDone = true; return; }));
|
||||
|
||||
let secondDone = false;
|
||||
let secondRes = sequentializer.setNext(() => timeout(3).then(() => { secondDone = true; return null; }));
|
||||
let secondRes = sequentializer.setNext(() => timeout(3).then(() => { secondDone = true; return; }));
|
||||
|
||||
let thirdDone = false;
|
||||
let thirdRes = sequentializer.setNext(() => timeout(4).then(() => { thirdDone = true; return null; }));
|
||||
let thirdRes = sequentializer.setNext(() => timeout(4).then(() => { thirdDone = true; return; }));
|
||||
|
||||
return Promise.all([firstRes, secondRes, thirdRes]).then(() => {
|
||||
assert.ok(pendingDone);
|
||||
|
||||
@@ -72,7 +72,7 @@ suite('Workbench - TextModelResolverService', () => {
|
||||
|
||||
return input.resolve().then(async model => {
|
||||
assert.ok(model);
|
||||
assert.equal(snapshotToString((model as ResourceEditorModel).createSnapshot()), 'Hello Test');
|
||||
assert.equal(snapshotToString((model as ResourceEditorModel).createSnapshot()!), 'Hello Test');
|
||||
|
||||
let disposed = false;
|
||||
let disposedPromise = new Promise(resolve => {
|
||||
|
||||
Reference in New Issue
Block a user