File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed
test/vscode-tests/no-workspace/databases Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import { AppCommandManager } from "../common/commands";
3232import { allowHttp } from "../config" ;
3333import { showAndLogInformationMessage } from "../common/logging" ;
3434import { AppOctokit } from "../common/octokit" ;
35+ import { getLanguageDisplayName } from "../common/query-language" ;
3536
3637/**
3738 * Prompts a user to fetch a database from a remote location. Database is assumed to be an archive file.
@@ -579,10 +580,23 @@ export async function promptForLanguage(
579580 return languages [ 0 ] ;
580581 }
581582
582- return await window . showQuickPick ( languages , {
583+ const items = languages
584+ . map ( ( language ) => ( {
585+ label : getLanguageDisplayName ( language ) ,
586+ description : language ,
587+ language,
588+ } ) )
589+ . sort ( ( a , b ) => a . label . localeCompare ( b . label ) ) ;
590+
591+ const selectedItem = await window . showQuickPick ( items , {
583592 placeHolder : "Select the database language to download:" ,
584593 ignoreFocusOut : true ,
585594 } ) ;
595+ if ( ! selectedItem ) {
596+ return undefined ;
597+ }
598+
599+ return selectedItem . language ;
586600}
587601
588602/**
Original file line number Diff line number Diff line change @@ -73,7 +73,12 @@ describe("database-fetcher", () => {
7373
7474 it ( "should convert a GitHub nwo to a database url" , async ( ) => {
7575 mockRequest . mockResolvedValue ( successfullMockApiResponse ) ;
76- quickPickSpy . mockResolvedValue ( mockedQuickPickItem ( "javascript" ) ) ;
76+ quickPickSpy . mockResolvedValue (
77+ mockedQuickPickItem ( {
78+ label : "JavaScript" ,
79+ language : "javascript" ,
80+ } ) ,
81+ ) ;
7782 const githubRepo = "github/codeql" ;
7883 const result = await convertGithubNwoToDatabaseUrl (
7984 githubRepo ,
@@ -94,7 +99,23 @@ describe("database-fetcher", () => {
9499 expect ( owner ) . toBe ( "github" ) ;
95100 expect ( quickPickSpy ) . toHaveBeenNthCalledWith (
96101 1 ,
97- [ "csharp" , "javascript" , "ql" ] ,
102+ [
103+ expect . objectContaining ( {
104+ label : "C#" ,
105+ description : "csharp" ,
106+ language : "csharp" ,
107+ } ) ,
108+ expect . objectContaining ( {
109+ label : "JavaScript" ,
110+ description : "javascript" ,
111+ language : "javascript" ,
112+ } ) ,
113+ expect . objectContaining ( {
114+ label : "ql" ,
115+ description : "ql" ,
116+ language : "ql" ,
117+ } ) ,
118+ ] ,
98119 expect . anything ( ) ,
99120 ) ;
100121 } ) ;
You can’t perform that action at this time.
0 commit comments