import * as path from 'path' ; import { EnvironmentVariableCollection , EnvironmentVariableMutator , ExtensionContext , ExtensionMode , Memento , Uri } from 'vscode' ; class MockMemento implements Memento { private telemetryGS : boolean ; constructor ( setGlobalState ) { this . telemetryGS = setGlobalState ; } public get ( key ) { if ( this . telemetryGS === true ) { return true ; } return undefined ; } public update ( key , value ) { return Promise . resolve ( ) ; } } class MockEnvironmentVariableCollection implements EnvironmentVariableCollection { public persistent = true ; public replace ( variable , value ) { throw new Error ( 'Method not implemented.' ) ; } public append ( variable , value ) { throw new Error ( 'Method not implemented.' ) ; } public prepend ( variable , value ) { throw new Error ( 'Method not implemented.' ) ; } public get ( variable ) { throw new Error ( 'Method not implemented.' ) ; } public forEach ( callback , thisArg ? ) { throw new Error ( 'Method not implemented.' ) ; } public delete ( variable ) { throw new Error ( 'Method not implemented.' ) ; } public clear ( ) { throw new Error ( 'Method not implemented.' ) ; } } export class MockContext implements ExtensionContext { constructor ( mm ) { this . globalState = new MockMemento ( mm ) ; } public storageUri : Uri | undefined ; public globalStorageUri : Uri = Uri . parse ( 'file://globalStorage' ) ; public logUri = Uri . parse ( 'file://logUri' ) ; public extensionMode = ExtensionMode . Test ; public extensionUri = Uri . parse ( 'file://test' ) ; public environmentVariableCollection = new MockEnvironmentVariableCollection ( ) ; public subscriptions : Array < { dispose ( ) : any ; } > = [ ] ; public workspaceState ! : Memento ; public globalState : Memento ; public extensionPath : string = 'myExtensionPath' ; public globalStoragePath = 'globalStatePath' ; public logPath = 'logPath' ; public asAbsolutePath ( relativePath ) { return path . join ( '../../package.json' ) ; } public storagePath : string = 'myStoragePath' ; }