From ed0420e3bbb10c6b837865ad49a0cae77f25ff92 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 15 Feb 2017 17:37:45 +0100 Subject: [PATCH] configuration resolver service tests: use mock line number --- .../test/node/configurationResolverService.test.ts | 6 ++++-- src/vs/workbench/test/workbenchTestServices.ts | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts index 1b8b94b15da..9f3c2925716 100644 --- a/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/node/configurationResolverService.test.ts @@ -18,10 +18,12 @@ suite('Configuration Resolver Service', () => { let configurationResolverService: IConfigurationResolverService; let envVariables: { [key: string]: string } = { key1: 'Value for Key1', key2: 'Value for Key2' }; let mockCommandService: MockCommandService; + let editorService: TestEditorService; setup(() => { mockCommandService = new MockCommandService(); - configurationResolverService = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, new TestEditorService(), TestEnvironmentService, new TestConfigurationService(), mockCommandService); + editorService = new TestEditorService(); + configurationResolverService = new ConfigurationResolverService(uri.parse('file:///VSCode/workspaceLocation'), envVariables, editorService, TestEnvironmentService, new TestConfigurationService(), mockCommandService); }); teardown(() => { @@ -42,7 +44,7 @@ suite('Configuration Resolver Service', () => { }); test('current selected line number', () => { - assert.strictEqual(configurationResolverService.resolve('abc ${lineNumber} xyz'), 'abc 15 xyz'); + assert.strictEqual(configurationResolverService.resolve('abc ${lineNumber} xyz'), `abc ${editorService.mockLineNumber} xyz`); }); test('substitute many', () => { diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index a574451b0c0..fe7b87be264 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -468,11 +468,13 @@ export class TestEditorService implements IWorkbenchEditorService { public activeEditorInput: IEditorInput; public activeEditorOptions: IEditorOptions; public activeEditorPosition: Position; + public mockLineNumber: number; private callback: (method: string) => void; constructor(callback?: (method: string) => void) { this.callback = callback || ((s: string) => { }); + this.mockLineNumber = 15; } public openEditors(inputs): Promise { @@ -505,7 +507,7 @@ export class TestEditorService implements IWorkbenchEditorService { getId: () => { return null; }, getControl: () => { return { - getSelection: () => { return { positionLineNumber: 15 }; } + getSelection: () => { return { positionLineNumber: this.mockLineNumber }; } }; }, focus: () => { }, -- GitLab