@@ -7,28 +7,32 @@ import { anything, instance, mock, verify, when } from 'ts-mockito';
77import { expect } from 'chai' ;
88import * as vscode from 'vscode' ;
99import { CopyImportPathCommand } from '../../../client/application/importPath/copyImportPathCommand' ;
10- import { ICommandManager , IWorkspaceService } from '../../../client/common/application/types' ;
10+ import { IClipboard , ICommandManager , IWorkspaceService } from '../../../client/common/application/types' ;
1111import * as pythonUtils from '../../../client/common/utils/pythonUtils' ;
12+ import { ClipboardService } from '../../../client/common/application/clipboard' ;
13+ import { CommandManager } from '../../../client/common/application/commandManager' ;
14+ import { WorkspaceService } from '../../../client/common/application/workspace' ;
1215
1316suite ( 'Copy Import Path Command' , ( ) => {
1417 let command : CopyImportPathCommand ;
1518 let commandManager : ICommandManager ;
1619 let workspaceService : IWorkspaceService ;
20+ let clipboard : IClipboard ;
1721 let originalGetSysPath : ( ) => string [ ] ;
1822
1923 let clipboardText = '' ;
2024
2125 setup ( ( ) => {
22- commandManager = mock < ICommandManager > ( ) ;
23- workspaceService = mock < IWorkspaceService > ( ) ;
24- command = new CopyImportPathCommand ( instance ( commandManager ) , instance ( workspaceService ) ) ;
26+ commandManager = mock ( CommandManager ) ;
27+ workspaceService = mock ( WorkspaceService ) ;
28+ clipboard = mock ( ClipboardService ) ;
29+ command = new CopyImportPathCommand ( instance ( commandManager ) , instance ( workspaceService ) , instance ( clipboard ) ) ;
2530 originalGetSysPath = pythonUtils . getSysPath ;
2631
2732 clipboardText = '' ;
28-
29- ( vscode . env . clipboard as typeof vscode . env . clipboard ) . writeText = async ( text : string ) => {
33+ when ( clipboard . writeText ( anything ( ) ) ) . thenCall ( async ( text : string ) => {
3034 clipboardText = text ;
31- } ;
35+ } ) ;
3236 } ) ;
3337
3438 teardown ( ( ) => {
@@ -43,8 +47,7 @@ suite('Copy Import Path Command', () => {
4347 test ( 'execute() – sys.path match takes precedence' , async ( ) => {
4448 const absPath = '/home/user/project/src/pkg/module.py' ;
4549 const uri = vscode . Uri . file ( absPath ) ;
46- ( ( pythonUtils as unknown ) as { getSysPath : ( ) => string [ ] } ) . getSysPath = originalGetSysPath ;
47- // ((pythonUtils as unknown) as { getSysPath: () => string[] }).getSysPath = () => ['/home/user/project/src'];
50+ ( ( pythonUtils as unknown ) as { getSysPath : ( ) => string [ ] } ) . getSysPath = ( ) => [ '/home/user/project/src' ] ;
4851
4952 when ( workspaceService . getWorkspaceFolder ( anything ( ) ) ) . thenReturn ( undefined ) ;
5053 ( ( vscode . window as unknown ) as { activeTextEditor : { document : { uri : vscode . Uri } } } ) . activeTextEditor = {
0 commit comments