|
4 | 4 | 'use strict'; |
5 | 5 |
|
6 | 6 | import * as assert from 'assert'; |
7 | | -import { use } from 'chai'; |
| 7 | +import { expect, use } from 'chai'; |
8 | 8 | import * as chaiAsPromised from 'chai-as-promised'; |
9 | | -import { anyString, anything, instance, mock, when } from 'ts-mockito'; |
| 9 | +import { anyString, anything, instance, mock, reset, verify, when } from 'ts-mockito'; |
10 | 10 | import { EventEmitter, TextDocument, Uri, WorkspaceFolder } from 'vscode'; |
11 | 11 | import { ApplicationShell } from '../../client/common/application/applicationShell'; |
12 | 12 | import { CommandManager } from '../../client/common/application/commandManager'; |
13 | 13 | import { DocumentManager } from '../../client/common/application/documentManager'; |
14 | 14 | import { IApplicationShell, ICommandManager, IDocumentManager, IWorkspaceService } from '../../client/common/application/types'; |
15 | 15 | import { WorkspaceService } from '../../client/common/application/workspace'; |
16 | 16 | import { ConfigurationService } from '../../client/common/configuration/service'; |
17 | | -import { STANDARD_OUTPUT_CHANNEL } from '../../client/common/constants'; |
| 17 | +import { Commands, STANDARD_OUTPUT_CHANNEL } from '../../client/common/constants'; |
18 | 18 | import { FileSystem } from '../../client/common/platform/fileSystem'; |
19 | 19 | import { IFileSystem } from '../../client/common/platform/types'; |
20 | 20 | import { ProcessService } from '../../client/common/process/proc'; |
@@ -160,6 +160,56 @@ suite('Workspace symbols main', () => { |
160 | 160 | assert.equal(shellOutput, 'Generating Tags'); |
161 | 161 | }); |
162 | 162 |
|
| 163 | + test('Should not show output channel when rebuilding on save', async () => { |
| 164 | + when(workspaceService.workspaceFolders).thenReturn(workspaceFolders); |
| 165 | + when(workspaceService.getWorkspaceFolder(anything())).thenReturn(workspaceFolders[0]); |
| 166 | + when(configurationService.getSettings(anything())).thenReturn({ |
| 167 | + workspaceSymbols: { |
| 168 | + ctagsPath, |
| 169 | + enabled: true, |
| 170 | + exclusionPatterns: [], |
| 171 | + rebuildOnFileSave: true, |
| 172 | + tagFilePath: 'foo' |
| 173 | + } |
| 174 | + } as any); |
| 175 | + reset(applicationShell); |
| 176 | + when(applicationShell.setStatusBarMessage(anyString(), anything())).thenThrow(new Error('Generating workspace tags failed with Error')); |
| 177 | + |
| 178 | + workspaceSymbols = new WorkspaceSymbols(instance(serviceContainer)); |
| 179 | + eventEmitter.fire({ uri: Uri.file('folder') } as any); |
| 180 | + await sleep(1); |
| 181 | + |
| 182 | + verify(outputChannel.show()).never(); |
| 183 | + }); |
| 184 | + |
| 185 | + test('Output channel is shown when using Command `Build Workspace symbols`', async () => { |
| 186 | + let buildWorkspaceSymbolsHandler!: Function; |
| 187 | + when(workspaceService.workspaceFolders).thenReturn(workspaceFolders); |
| 188 | + when(workspaceService.getWorkspaceFolder(anything())).thenReturn(workspaceFolders[0]); |
| 189 | + when(configurationService.getSettings(anything())).thenReturn({ |
| 190 | + workspaceSymbols: { |
| 191 | + ctagsPath, |
| 192 | + enabled: true, |
| 193 | + exclusionPatterns: [], |
| 194 | + rebuildOnFileSave: true, |
| 195 | + tagFilePath: 'foo' |
| 196 | + } |
| 197 | + } as any); |
| 198 | + reset(commandManager); |
| 199 | + when(commandManager.registerCommand(anything(), anything())).thenCall((commandID, cb) => { |
| 200 | + expect(commandID).to.equal(Commands.Build_Workspace_Symbols); |
| 201 | + buildWorkspaceSymbolsHandler = cb; |
| 202 | + return mockDisposable; |
| 203 | + }); |
| 204 | + reset(applicationShell); |
| 205 | + when(applicationShell.setStatusBarMessage(anyString(), anything())).thenThrow(new Error('Generating workspace tags failed with Error')); |
| 206 | + |
| 207 | + workspaceSymbols = new WorkspaceSymbols(instance(serviceContainer)); |
| 208 | + await buildWorkspaceSymbolsHandler(); |
| 209 | + |
| 210 | + verify(outputChannel.show()).once(); |
| 211 | + }); |
| 212 | + |
163 | 213 | test('Should not rebuild on save if the setting is disabled', () => { |
164 | 214 | when(workspaceService.workspaceFolders).thenReturn(workspaceFolders); |
165 | 215 | when(configurationService.getSettings(anything())).thenReturn({ |
|
0 commit comments