@@ -32,6 +32,9 @@ describe("SkeletonQueryWizard", () => {
3232 let downloadGitHubDatabaseSpy : jest . SpiedFunction <
3333 typeof databaseFetcher . downloadGitHubDatabase
3434 > ;
35+ let askForGitHubRepoSpy : jest . SpiedFunction <
36+ typeof databaseFetcher . askForGitHubRepo
37+ > ;
3538 let openTextDocumentSpy : jest . SpiedFunction <
3639 typeof workspace . openTextDocument
3740 > ;
@@ -42,6 +45,7 @@ describe("SkeletonQueryWizard", () => {
4245 const mockDatabaseManager = mockedObject < DatabaseManager > ( {
4346 setCurrentDatabaseItem : jest . fn ( ) ,
4447 digForDatabaseItem : jest . fn ( ) ,
48+ digForDatabaseWithSameLanguage : jest . fn ( ) ,
4549 } ) ;
4650 const mockCli = mockedObject < CodeQLCliServer > ( {
4751 resolveLanguages : jest
@@ -58,6 +62,8 @@ describe("SkeletonQueryWizard", () => {
5862 getSupportedLanguages : jest . fn ( ) ,
5963 } ) ;
6064
65+ jest . spyOn ( extLogger , "log" ) . mockResolvedValue ( undefined ) ;
66+
6167 beforeEach ( async ( ) => {
6268 dir = tmp . dirSync ( {
6369 prefix : "skeleton_query_wizard_" ,
@@ -101,6 +107,10 @@ describe("SkeletonQueryWizard", () => {
101107 mockDatabaseManager ,
102108 token ,
103109 ) ;
110+
111+ askForGitHubRepoSpy = jest
112+ . spyOn ( databaseFetcher , "askForGitHubRepo" )
113+ . mockResolvedValue ( QUERY_LANGUAGE_TO_DATABASE_REPO [ chosenLanguage ] ) ;
104114 } ) ;
105115
106116 afterEach ( async ( ) => {
@@ -250,10 +260,30 @@ describe("SkeletonQueryWizard", () => {
250260 . mockResolvedValue ( undefined ) ;
251261 } ) ;
252262
253- it ( "should download a new database for language" , async ( ) => {
254- await wizard . execute ( ) ;
263+ describe ( "if the user choses to downloaded the suggested database from GitHub" , ( ) => {
264+ it ( "should download a new database for language" , async ( ) => {
265+ await wizard . execute ( ) ;
266+
267+ expect ( askForGitHubRepoSpy ) . toHaveBeenCalled ( ) ;
268+ expect ( downloadGitHubDatabaseSpy ) . toHaveBeenCalled ( ) ;
269+ } ) ;
270+ } ) ;
271+
272+ describe ( "if the user choses to download a different database from GitHub than the one suggested" , ( ) => {
273+ beforeEach ( ( ) => {
274+ const chosenGitHubRepo = "pickles-owner/pickles-repo" ;
275+
276+ askForGitHubRepoSpy = jest
277+ . spyOn ( databaseFetcher , "askForGitHubRepo" )
278+ . mockResolvedValue ( chosenGitHubRepo ) ;
279+ } ) ;
280+
281+ it ( "should download the newly chosen database" , async ( ) => {
282+ await wizard . execute ( ) ;
255283
256- expect ( downloadGitHubDatabaseSpy ) . toHaveBeenCalled ( ) ;
284+ expect ( askForGitHubRepoSpy ) . toHaveBeenCalled ( ) ;
285+ expect ( downloadGitHubDatabaseSpy ) . toHaveBeenCalled ( ) ;
286+ } ) ;
257287 } ) ;
258288 } ) ;
259289 } ) ;
0 commit comments