mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
#68546 Tests
This commit is contained in:
+56
-8
@@ -140,10 +140,66 @@ suite('WorkspaceContextService - Folder', () => {
|
||||
test('isCurrentWorkspace() => false', () => {
|
||||
assert.ok(!workspaceContextService.isCurrentWorkspace(URI.file(workspaceResource + 'abc')));
|
||||
});
|
||||
|
||||
test('workspace is complete', () => workspaceContextService.getCompleteWorkspace());
|
||||
});
|
||||
|
||||
suite('WorkspaceContextService - Workspace', () => {
|
||||
|
||||
let parentResource: string, testObject: WorkspaceService, instantiationService: TestInstantiationService;
|
||||
|
||||
setup(() => {
|
||||
return setUpWorkspace(['a', 'b'])
|
||||
.then(({ parentDir, configPath }) => {
|
||||
|
||||
parentResource = parentDir;
|
||||
|
||||
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json'));
|
||||
const workspaceService = new WorkspaceService(environmentService);
|
||||
|
||||
instantiationService = <TestInstantiationService>workbenchInstantiationService();
|
||||
instantiationService.stub(IWorkspaceContextService, workspaceService);
|
||||
instantiationService.stub(IConfigurationService, workspaceService);
|
||||
instantiationService.stub(IEnvironmentService, environmentService);
|
||||
|
||||
return workspaceService.initialize(getWorkspaceIdentifier(configPath)).then(() => {
|
||||
workspaceService.acquireInstantiationService(instantiationService);
|
||||
testObject = workspaceService;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
teardown(() => {
|
||||
if (testObject) {
|
||||
(<WorkspaceService>testObject).dispose();
|
||||
}
|
||||
if (parentResource) {
|
||||
return pfs.del(parentResource, os.tmpdir());
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
|
||||
test('workspace folders', () => {
|
||||
const actual = testObject.getWorkspace().folders;
|
||||
|
||||
assert.equal(actual.length, 2);
|
||||
assert.equal(path.basename(actual[0].uri.fsPath), 'a');
|
||||
assert.equal(path.basename(actual[1].uri.fsPath), 'b');
|
||||
});
|
||||
|
||||
test('getWorkbenchState()', () => {
|
||||
const actual = testObject.getWorkbenchState();
|
||||
|
||||
assert.equal(actual, WorkbenchState.WORKSPACE);
|
||||
});
|
||||
|
||||
|
||||
test('workspace is complete', () => testObject.getCompleteWorkspace());
|
||||
|
||||
});
|
||||
|
||||
suite('WorkspaceContextService - Workspace Editing', () => {
|
||||
|
||||
let parentResource: string, testObject: WorkspaceService, instantiationService: TestInstantiationService, fileChangeEvent: Emitter<FileChangesEvent> = new Emitter<FileChangesEvent>();
|
||||
|
||||
setup(() => {
|
||||
@@ -186,14 +242,6 @@ suite('WorkspaceContextService - Workspace', () => {
|
||||
return undefined;
|
||||
});
|
||||
|
||||
test('workspace folders', () => {
|
||||
const actual = testObject.getWorkspace().folders;
|
||||
|
||||
assert.equal(actual.length, 2);
|
||||
assert.equal(path.basename(actual[0].uri.fsPath), 'a');
|
||||
assert.equal(path.basename(actual[1].uri.fsPath), 'b');
|
||||
});
|
||||
|
||||
test('add folders', () => {
|
||||
const workspaceDir = path.dirname(testObject.getWorkspace().folders[0].uri.fsPath);
|
||||
return testObject.addFolders([{ uri: URI.file(path.join(workspaceDir, 'd')) }, { uri: URI.file(path.join(workspaceDir, 'c')) }])
|
||||
|
||||
Reference in New Issue
Block a user