@@ -36,27 +36,24 @@ const mockLinkStatisticsService = {
3636}
3737
3838describe ( 'RedirectService' , ( ) => {
39- let redirectService : RedirectService
39+ // Create service instance with mocked dependencies
40+ const redirectService = new RedirectService (
41+ mockUrlRepository as unknown as UrlRepositoryInterface ,
42+ mockCrawlerCheckService as unknown as CrawlerCheckService ,
43+ mockCookieArrayReducerService as unknown as CookieArrayReducerService ,
44+ mockLinkStatisticsService as unknown as LinkStatisticsService ,
45+ )
4046
4147 beforeEach ( ( ) => {
42- // Reset mocks
4348 jest . clearAllMocks ( )
4449
45- // Setup default mock returns
50+ // Setup default mock returns after clearing
4651 mockUrlRepository . getLongUrl . mockResolvedValue ( 'https://example.com' )
4752 mockCrawlerCheckService . isCrawler . mockReturnValue ( false )
4853 mockCookieArrayReducerService . userHasVisitedShortlink . mockReturnValue ( false )
4954 mockCookieArrayReducerService . writeShortlinkToCookie . mockReturnValue ( [
5055 'test' ,
5156 ] )
52-
53- // Create service instance with mocked dependencies
54- redirectService = new RedirectService (
55- mockUrlRepository as unknown as UrlRepositoryInterface ,
56- mockCrawlerCheckService as unknown as CrawlerCheckService ,
57- mockCookieArrayReducerService as unknown as CookieArrayReducerService ,
58- mockLinkStatisticsService as unknown as LinkStatisticsService ,
59- )
6057 } )
6158
6259 describe ( 'redirectFor' , ( ) => {
0 commit comments