@@ -112,12 +112,20 @@ describe('getCacheKey', () => {
112112 fileContent : 'export default "foo"' ,
113113 fileName : 'foo.ts' ,
114114 jestConfigStr : '{"foo": "bar"}' ,
115+ options : { instrument : false , rootDir : '/foo' } ,
115116 }
116- const key1 = tr . getCacheKey ( input . fileContent , input . fileName , input . jestConfigStr )
117- const key2 = tr . getCacheKey ( input . fileContent , 'bar.ts' , input . jestConfigStr )
118- const key3 = tr . getCacheKey ( input . fileContent , input . fileName , '{}' )
119- expect ( key2 ) . not . toBe ( key1 )
120- expect ( key3 ) . not . toBe ( key1 )
121- expect ( key3 ) . not . toBe ( key2 )
117+ const keys = [
118+ tr . getCacheKey ( input . fileContent , input . fileName , input . jestConfigStr , input . options ) ,
119+ tr . getCacheKey ( input . fileContent , 'bar.ts' , input . jestConfigStr , input . options ) ,
120+ tr . getCacheKey ( input . fileContent , input . fileName , '{}' , input . options ) ,
121+ tr . getCacheKey ( input . fileContent , input . fileName , '{}' , { ...input . options , instrument : true } ) ,
122+ tr . getCacheKey ( input . fileContent , input . fileName , '{}' , { ...input . options , rootDir : '/bar' } ) ,
123+ ]
124+ // each key should have correct length
125+ for ( const key of keys ) {
126+ expect ( key ) . toHaveLength ( 40 )
127+ }
128+ // unique array should have same length
129+ expect ( keys . filter ( ( k , i , all ) => all . indexOf ( k ) === i ) ) . toHaveLength ( keys . length )
122130 } )
123131} )
0 commit comments