@@ -12,7 +12,6 @@ import {
1212import { POWERTOOLS_BASE_URL } from '../../src/constants.ts' ;
1313import { schema , tool } from '../../src/tools/fetchDocPage/index.ts' ;
1414import {
15- generateCacheKey ,
1615 getRemotePage ,
1716 getRemotePageETag ,
1817} from '../../src/tools/fetchDocPage/utils.ts' ;
@@ -38,6 +37,10 @@ describe('schema', () => {
3837 type : 'semver' ,
3938 url : `${ POWERTOOLS_BASE_URL } /typescript/1.2.4/features/metrics/` ,
4039 } ,
40+ {
41+ type : 'dotnet no version' ,
42+ url : `${ POWERTOOLS_BASE_URL } /dotnet/features/metrics/` ,
43+ } ,
4144 ] ) ( 'parses a valid URL ($type)' , ( { url } ) => {
4245 // Act
4346 const result = schema . url . parse ( url ) ;
@@ -282,21 +285,6 @@ describe('utils', () => {
282285 ) ;
283286 } ) ;
284287 } ) ;
285-
286- describe ( 'generateCacheKey' , ( ) => {
287- it ( 'generates a cache key based on the URL' , ( ) => {
288- // Prepare
289- const url = new URL (
290- `${ POWERTOOLS_BASE_URL } /typescript/latest/features/metrics/index.md`
291- ) ;
292-
293- // Act
294- const cacheKey = generateCacheKey ( { url } ) ;
295-
296- // Assess
297- expect ( cacheKey ) . toBe ( 'typescript/latest/features/metrics/index.md' ) ;
298- } ) ;
299- } ) ;
300288} ) ;
301289
302290describe ( 'tool' , ( ) => {
@@ -358,7 +346,7 @@ describe('tool', () => {
358346 data : Buffer . from ( expectedContent ) ,
359347 } ) ;
360348 const url = new URL ( `${ baseUrl } metrics/index.md` ) ;
361- const cacheKey = generateCacheKey ( { url } ) ;
349+ const cacheKey = url . pathname ;
362350
363351 // Act
364352 const result = await tool ( { url } ) ;
@@ -387,7 +375,7 @@ describe('tool', () => {
387375 // Prepare
388376 mocks . getFromCache . mockRejectedValueOnce ( new Error ( 'Cache miss' ) ) ;
389377 const url = new URL ( `${ baseUrl } no-etag-for-some-reason.md` ) ;
390- const cacheKey = generateCacheKey ( { url } ) ;
378+ const cacheKey = url . pathname ;
391379
392380 // Act
393381 const result = await tool ( { url } ) ;
@@ -413,7 +401,7 @@ describe('tool', () => {
413401 data : Buffer . from ( '54321' ) ,
414402 } ) ;
415403 const url = new URL ( `${ baseUrl } metrics/index.md` ) ;
416- const cacheKey = generateCacheKey ( { url } ) ;
404+ const cacheKey = url . pathname ;
417405 const expectedContent =
418406 'Metrics is a feature of PowerTools for TypeScript.' ;
419407
@@ -453,7 +441,7 @@ describe('tool', () => {
453441 } ) ;
454442 mocks . getFromCache . mockRejectedValueOnce ( new Error ( 'Cache miss' ) ) ;
455443 const url = new URL ( `${ baseUrl } metrics/index.md` ) ;
456- const cacheKey = generateCacheKey ( { url } ) ;
444+ const cacheKey = url . pathname ;
457445 const expectedContent =
458446 'Metrics is a feature of PowerTools for TypeScript.' ;
459447
0 commit comments