@@ -36,17 +36,16 @@ describe('programOptionsCache', () => {
3636
3737 describe ( 'getCachedProgramOptions' , ( ) => {
3838 it ( 'should return undefined for cache miss' , ( ) => {
39- const result = getCachedProgramOptions ( '/project/tsconfig.json:undefined ' ) ;
39+ const result = getCachedProgramOptions ( '/project/tsconfig.json' ) ;
4040 expect ( result ) . toBeUndefined ( ) ;
4141 } ) ;
4242
4343 it ( 'should return cached options for cache hit' , ( ) => {
4444 const tsConfig = path . join ( fixtures , 'tsconfig.json' ) ;
4545 const options = createProgramOptions ( tsConfig ) ;
46- const cacheKey = `${ tsConfig } :custom` ;
4746
48- setCachedProgramOptions ( cacheKey , options ) ;
49- const result = getCachedProgramOptions ( cacheKey ) ;
47+ setCachedProgramOptions ( tsConfig , options , 'custom' ) ;
48+ const result = getCachedProgramOptions ( tsConfig , 'custom' ) ;
5049
5150 expect ( result ) . toBe ( options ) ;
5251 } ) ;
@@ -56,11 +55,10 @@ describe('programOptionsCache', () => {
5655 it ( 'should store options in cache' , ( ) => {
5756 const tsConfig = path . join ( fixtures , 'tsconfig.json' ) ;
5857 const options = createProgramOptions ( tsConfig ) ;
59- const cacheKey = `${ tsConfig } :custom` ;
6058
61- setCachedProgramOptions ( cacheKey , options ) ;
59+ setCachedProgramOptions ( tsConfig , options , 'custom' ) ;
6260
63- expect ( getCachedProgramOptions ( cacheKey ) ) . toBe ( options ) ;
61+ expect ( getCachedProgramOptions ( tsConfig , 'custom' ) ) . toBe ( options ) ;
6462 } ) ;
6563
6664 it ( 'should handle different cache keys for same tsconfig with different contents' , ( ) => {
@@ -72,14 +70,11 @@ describe('programOptionsCache', () => {
7270
7371 const options2 = createProgramOptions ( tsConfig ) ;
7472
75- const cacheKey1 = ` ${ tsConfig } : content1` ;
76- const cacheKey2 = ` ${ tsConfig } : content2` ;
73+ setCachedProgramOptions ( tsConfig , options1 , ' content1' ) ;
74+ setCachedProgramOptions ( tsConfig , options2 , ' content2' ) ;
7775
78- setCachedProgramOptions ( cacheKey1 , options1 ) ;
79- setCachedProgramOptions ( cacheKey2 , options2 ) ;
80-
81- expect ( getCachedProgramOptions ( cacheKey1 ) ) . toBe ( options1 ) ;
82- expect ( getCachedProgramOptions ( cacheKey2 ) ) . toBe ( options2 ) ;
76+ expect ( getCachedProgramOptions ( tsConfig , 'content1' ) ) . toBe ( options1 ) ;
77+ expect ( getCachedProgramOptions ( tsConfig , 'content2' ) ) . toBe ( options2 ) ;
8378 } ) ;
8479
8580 it ( 'should overwrite existing cache entry' , ( ) => {
@@ -91,12 +86,11 @@ describe('programOptionsCache', () => {
9186 clearTsConfigContentCache ( ) ;
9287
9388 const options2 = createProgramOptions ( tsConfig2 ) ;
94- const cacheKey = 'shared-key' ;
9589
96- setCachedProgramOptions ( cacheKey , options1 ) ;
97- setCachedProgramOptions ( cacheKey , options2 ) ;
90+ setCachedProgramOptions ( 'shared-key' , options1 ) ;
91+ setCachedProgramOptions ( 'shared-key' , options2 ) ;
9892
99- expect ( getCachedProgramOptions ( cacheKey ) ) . toBe ( options2 ) ;
93+ expect ( getCachedProgramOptions ( 'shared-key' ) ) . toBe ( options2 ) ;
10094 } ) ;
10195 } ) ;
10296
0 commit comments