11import {
2- commands ,
32 EnvironmentVariableCollection ,
43 EnvironmentVariableMutator ,
54 Event ,
@@ -41,6 +40,7 @@ import {
4140import { reportStreamProgress } from "../../../src/progress" ;
4241import { QueryLanguage } from "../../../src/common/query-language" ;
4342import { Setting } from "../../../src/config" ;
43+ import { createMockCommandManager } from "../../__mocks__/commandsMock" ;
4444
4545describe ( "helpers" , ( ) => {
4646 describe ( "Invocation rate limiter" , ( ) => {
@@ -612,13 +612,11 @@ describe("prepareCodeTour", () => {
612612 await mkdir ( tourDirPath ) ;
613613
614614 // spy that we open the workspace file by calling the 'vscode.openFolder' command
615- const commandSpy = jest . spyOn ( commands , "executeCommand" ) ;
616- commandSpy . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
617-
618- await prepareCodeTour ( ) ;
615+ const executeCommand = jest . fn ( ) ;
616+ await prepareCodeTour ( createMockCommandManager ( { executeCommand } ) ) ;
619617
620618 expect ( showInformationMessageSpy ) . toHaveBeenCalled ( ) ;
621- expect ( commandSpy ) . toHaveBeenCalledWith (
619+ expect ( executeCommand ) . toHaveBeenCalledWith (
622620 "vscode.openFolder" ,
623621 expect . objectContaining ( {
624622 path : Uri . parse ( tutorialWorkspacePath ) . fsPath ,
@@ -641,12 +639,10 @@ describe("prepareCodeTour", () => {
641639 await mkdir ( tourDirPath ) ;
642640
643641 // spy that we open the workspace file by calling the 'vscode.openFolder' command
644- const commandSpy = jest . spyOn ( commands , "executeCommand" ) ;
645- commandSpy . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
646-
647- await prepareCodeTour ( ) ;
642+ const executeCommand = jest . fn ( ) ;
643+ await prepareCodeTour ( createMockCommandManager ( { executeCommand } ) ) ;
648644
649- expect ( commandSpy ) . not . toHaveBeenCalled ( ) ;
645+ expect ( executeCommand ) . not . toHaveBeenCalled ( ) ;
650646 } ) ;
651647 } ) ;
652648 } ) ;
@@ -658,24 +654,20 @@ describe("prepareCodeTour", () => {
658654 await mkdir ( tourDirPath ) ;
659655
660656 // spy that we open the workspace file by calling the 'vscode.openFolder' command
661- const commandSpy = jest . spyOn ( commands , "executeCommand" ) ;
662- commandSpy . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
657+ const executeCommand = jest . fn ( ) ;
658+ await prepareCodeTour ( createMockCommandManager ( { executeCommand } ) ) ;
663659
664- await prepareCodeTour ( ) ;
665-
666- expect ( commandSpy ) . not . toHaveBeenCalled ( ) ;
660+ expect ( executeCommand ) . not . toHaveBeenCalled ( ) ;
667661 } ) ;
668662 } ) ;
669663
670664 describe ( "if we're in a different repo with no tour" , ( ) => {
671665 it ( "should not open the tutorial workspace" , async ( ) => {
672666 // spy that we open the workspace file by calling the 'vscode.openFolder' command
673- const commandSpy = jest . spyOn ( commands , "executeCommand" ) ;
674- commandSpy . mockImplementation ( ( ) => Promise . resolve ( ) ) ;
675-
676- await prepareCodeTour ( ) ;
667+ const executeCommand = jest . fn ( ) ;
668+ await prepareCodeTour ( createMockCommandManager ( { executeCommand } ) ) ;
677669
678- expect ( commandSpy ) . not . toHaveBeenCalled ( ) ;
670+ expect ( executeCommand ) . not . toHaveBeenCalled ( ) ;
679671 } ) ;
680672 } ) ;
681673} ) ;
0 commit comments