1+ import { checkExistKey } from '../checkExistApiConfig' ;
2+ import { ApiConfiguration } from '../api' ;
3+
4+ describe ( 'checkExistKey' , ( ) => {
5+ it ( 'should return false for undefined config' , ( ) => {
6+ expect ( checkExistKey ( undefined ) ) . toBe ( false ) ;
7+ } ) ;
8+
9+ it ( 'should return false for empty config' , ( ) => {
10+ const config : ApiConfiguration = { } ;
11+ expect ( checkExistKey ( config ) ) . toBe ( false ) ;
12+ } ) ;
13+
14+ it ( 'should return true when one key is defined' , ( ) => {
15+ const config : ApiConfiguration = {
16+ apiKey : 'test-key'
17+ } ;
18+ expect ( checkExistKey ( config ) ) . toBe ( true ) ;
19+ } ) ;
20+
21+ it ( 'should return true when multiple keys are defined' , ( ) => {
22+ const config : ApiConfiguration = {
23+ apiKey : 'test-key' ,
24+ glamaApiKey : 'glama-key' ,
25+ openRouterApiKey : 'openrouter-key'
26+ } ;
27+ expect ( checkExistKey ( config ) ) . toBe ( true ) ;
28+ } ) ;
29+
30+ it ( 'should return true when only non-key fields are undefined' , ( ) => {
31+ const config : ApiConfiguration = {
32+ apiKey : 'test-key' ,
33+ apiProvider : undefined ,
34+ anthropicBaseUrl : undefined
35+ } ;
36+ expect ( checkExistKey ( config ) ) . toBe ( true ) ;
37+ } ) ;
38+
39+ it ( 'should return false when all key fields are undefined' , ( ) => {
40+ const config : ApiConfiguration = {
41+ apiKey : undefined ,
42+ glamaApiKey : undefined ,
43+ openRouterApiKey : undefined ,
44+ awsRegion : undefined ,
45+ vertexProjectId : undefined ,
46+ openAiApiKey : undefined ,
47+ ollamaModelId : undefined ,
48+ lmStudioModelId : undefined ,
49+ geminiApiKey : undefined ,
50+ openAiNativeApiKey : undefined ,
51+ deepSeekApiKey : undefined ,
52+ vsCodeLmModelSelector : undefined
53+ } ;
54+ expect ( checkExistKey ( config ) ) . toBe ( false ) ;
55+ } ) ;
56+ } ) ;
0 commit comments