@@ -21,7 +21,7 @@ import {
2121 CrawlerCheckService ,
2222 RedirectService ,
2323} from '../services'
24- // import { RedirectDestination } from '../../../repositories/types'
24+ import { RedirectDestination } from '../../../repositories/types'
2525
2626const redisMockClient = redisMock . createClient ( )
2727const sequelizeMock = new SequelizeMock ( )
@@ -520,50 +520,40 @@ describe('redirect API tests', () => {
520520 test ( 'url does exists in cache but not db' , async ( ) => {
521521 const req = createRequestWithShortUrl ( 'Aaa' )
522522 const res = httpMocks . createResponse ( )
523- // FIXME: Update to use the new RedirectDestination type
524- // const redirectDestination: RedirectDestination = {
525- // longUrl: 'aa',
526- // isFile: false,
527- // safeBrowsingExpiry: new Date(Date.now() + 1000).toISOString(),
528- // }
529-
530- // redisMockClient.set('aaa', JSON.stringify(redirectDestination))
531- redisMockClient . set ( 'aaa' , 'aa' )
523+ const redirectDestination : RedirectDestination = {
524+ longUrl : 'aa' ,
525+ isFile : false ,
526+ safeBrowsingExpiry : new Date ( Date . now ( ) + 1000 ) . toISOString ( ) ,
527+ }
528+
529+ redisMockClient . set ( 'aaa' , JSON . stringify ( redirectDestination ) )
532530 mockDbEmpty ( )
533531
534532 await container
535533 . get < RedirectController > ( DependencyIds . redirectController )
536534 . redirect ( req , res )
537535
538- // expect(res.statusCode).toBe(302)
539- // NOTE: This is 404 now as the safe browsing repository needs to be updated
540- // but it will be 302 once the safe browsing expiry is stored in redis
541- expect ( res . statusCode ) . toBe ( 404 )
542- // expect(res._getRedirectUrl()).toBe('aa')
536+ expect ( res . statusCode ) . toBe ( 302 )
537+ expect ( res . _getRedirectUrl ( ) ) . toBe ( 'aa' )
543538 } )
544539
545540 test ( 'url in cache and db is down' , async ( ) => {
546541 const req = createRequestWithShortUrl ( 'Aaa' )
547542 const res = httpMocks . createResponse ( )
548- // FIXME: Update to use the new RedirectDestination type
549- // const redirectDestination: RedirectDestination = {
550- // longUrl: 'aa',
551- // isFile: false,
552- // safeBrowsingExpiry: new Date(Date.now() + 1000).toISOString(),
553- // }
543+ const redirectDestination : RedirectDestination = {
544+ longUrl : 'aa' ,
545+ isFile : false ,
546+ safeBrowsingExpiry : new Date ( Date . now ( ) + 1000 ) . toISOString ( ) ,
547+ }
554548
555549 mockDbDown ( )
556- // redisMockClient.set('aaa', JSON.stringify(redirectDestination))
557- redisMockClient . set ( 'aaa' , 'aa' )
550+ redisMockClient . set ( 'aaa' , JSON . stringify ( redirectDestination ) )
558551
559552 await container
560553 . get < RedirectController > ( DependencyIds . redirectController )
561554 . redirect ( req , res )
562- // expect(res.statusCode).toBe(302)
563- // NOTE: This is 404 now as the safe browsing repository needs to be updated
564- // but it will be 302 once the safe browsing expiry is stored in redis
565- expect ( res . statusCode ) . toBe ( 404 )
566- // expect(res._getRedirectUrl()).toBe('aa')
555+ expect ( res . statusCode ) . toBe ( 302 )
556+ expect ( res . _getRedirectUrl ( ) ) . toBe ( 'aa' )
567557 } )
568558
569559 test ( 'retrieval of gtag for transition page' , async ( ) => {
0 commit comments