'use strict' ; import * as TypeMoq from 'typemoq' ; import * as vscode from 'vscode' ; import * as vscodeMocks from './vsc' ; type VSCode = typeof vscode ; const mockedVSCode = { } ; export const mockedVSCodeNamespaces = { } ; function generateMock < K extends keyof VSCode > ( name ) { const mockedObj = TypeMoq . Mock . ofType < VSCode [ K ] > ( ) ; ( mockedVSCode as any ) [ name ] = mockedObj . object ; mockedVSCodeNamespaces [ name ] = mockedObj as any ; } class MockClipboard { private text = '' ; public readText ( ) { return Promise . resolve ( this . text ) ; } public async writeText ( value ) { this . text = value ; } } export function initialize ( ) { generateMock ( 'workspace' ) ; generateMock ( 'window' ) ; generateMock ( 'commands' ) ; generateMock ( 'languages' ) ; generateMock ( 'env' ) ; generateMock ( 'debug' ) ; generateMock ( 'scm' ) ; const clipboard = new MockClipboard ( ) ; mockedVSCodeNamespaces . env ?. setup ( e => e . clipboard ) . returns ( ( ) => clipboard ) ; return mockedVSCode ; } mockedVSCode . Disposable = vscodeMocks . vscMock . Disposable as any ; mockedVSCode . CodeAction = vscodeMocks . vscMock . CodeAction ; mockedVSCode . EventEmitter = vscodeMocks . vscMock . EventEmitter ; mockedVSCode . CancellationTokenSource = vscodeMocks . vscMock . CancellationTokenSource ; mockedVSCode . SymbolKind = vscodeMocks . vscMock . SymbolKind ; mockedVSCode . IndentAction = vscodeMocks . vscMock . IndentAction ; mockedVSCode . Uri = vscodeMocks . vscUri . URI as any ; mockedVSCode . Range = vscodeMocks . vscMockExtHostedTypes . Range ; mockedVSCode . Position = vscodeMocks . vscMockExtHostedTypes . Position ; mockedVSCode . Selection = vscodeMocks . vscMockExtHostedTypes . Selection ; mockedVSCode . Location = vscodeMocks . vscMockExtHostedTypes . Location ; mockedVSCode . SymbolInformation = vscodeMocks . vscMockExtHostedTypes . SymbolInformation ; mockedVSCode . CompletionItem = vscodeMocks . vscMockExtHostedTypes . CompletionItem ; mockedVSCode . CodeLens = vscodeMocks . vscMockExtHostedTypes . CodeLens ; mockedVSCode . DiagnosticSeverity = vscodeMocks . vscMockExtHostedTypes . DiagnosticSeverity ; mockedVSCode . SnippetString = vscodeMocks . vscMockExtHostedTypes . SnippetString ; mockedVSCode . ConfigurationTarget = vscodeMocks . vscMockExtHostedTypes . ConfigurationTarget ; mockedVSCode . StatusBarAlignment = vscodeMocks . vscMockExtHostedTypes . StatusBarAlignment ; mockedVSCode . SignatureHelp = vscodeMocks . vscMockExtHostedTypes . SignatureHelp ; mockedVSCode . DocumentLink = vscodeMocks . vscMockExtHostedTypes . DocumentLink ; mockedVSCode . TextEdit = vscodeMocks . vscMockExtHostedTypes . TextEdit ; mockedVSCode . WorkspaceEdit = vscodeMocks . vscMockExtHostedTypes . WorkspaceEdit ; mockedVSCode . RelativePattern = vscodeMocks . vscMockExtHostedTypes . RelativePattern ; mockedVSCode . ProgressLocation = vscodeMocks . vscMockExtHostedTypes . ProgressLocation ; mockedVSCode . ViewColumn = vscodeMocks . vscMockExtHostedTypes . ViewColumn ; mockedVSCode . TextEditorRevealType = vscodeMocks . vscMockExtHostedTypes . TextEditorRevealType ; mockedVSCode . TreeItem = vscodeMocks . vscMockExtHostedTypes . TreeItem ; mockedVSCode . TreeItemCollapsibleState = vscodeMocks . vscMockExtHostedTypes . TreeItemCollapsibleState ; mockedVSCode . CodeActionKind = vscodeMocks . vscMock . CodeActionKind ; mockedVSCode . DebugAdapterExecutable = vscodeMocks . vscMock . DebugAdapterExecutable ; mockedVSCode . DebugAdapterServer = vscodeMocks . vscMock . DebugAdapterServer ; mockedVSCode . FileType = vscodeMocks . vscMock . FileType ; const extensions = TypeMoq . Mock . ofType < typeof vscode . extensions > ( ) ; extensions . setup ( e => e . all ) . returns ( ( ) => [ ] ) ; const extension = TypeMoq . Mock . ofType < vscode . Extension < any > > ( ) ; const packageJson = TypeMoq . Mock . ofType < any > ( ) ; const contributes = TypeMoq . Mock . ofType < any > ( ) ; extension . setup ( e => e . packageJSON ) . returns ( ( ) => packageJson . object ) ; packageJson . setup ( p => p . contributes ) . returns ( ( ) => contributes . object ) ; contributes . setup ( p => p . debuggers ) . returns ( ( ) => [ { aiKey : '' } ] ) ; extensions . setup ( e => e . getExtension ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => extension . object ) ; mockedVSCode . extensions = extensions . object ;