@@ -317,65 +317,39 @@ describe('PostService', () => {
317317 } ,
318318 ] ;
319319
320- it ( '게시물 ID로 상세 통계 조회' , async ( ) => {
321- // Arrange
322- postRepo . findPostByPostId . mockResolvedValue ( mockPostStats ) ;
323-
324- // Act
325- const result = await postService . getPostByPostId ( 1 ) ;
326-
327- // Assert
328- expect ( result ) . toEqual ( expectedTransformedStats ) ;
329- expect ( postRepo . findPostByPostId ) . toHaveBeenCalledWith ( 1 , undefined , undefined ) ;
330- } ) ;
331-
332320 it ( '시작일과 종료일을 지정하여 상세 통계 조회' , async ( ) => {
333- // Arrange
334321 const start = '2025-03-01' ;
335322 const end = '2025-03-10' ;
336323
337324 postRepo . findPostByPostId . mockResolvedValue ( mockPostStats ) ;
338325
339- // Act
340326 const result = await postService . getPostByPostId ( 1 , start , end ) ;
341-
342- // Assert
343327 expect ( result ) . toEqual ( expectedTransformedStats ) ;
344- expect ( postRepo . findPostByPostId ) . toHaveBeenCalledWith ( 1 , start , end ) ;
328+ expect ( postRepo . findPostByPostId ) . toHaveBeenCalledWith ( 1 , ` ${ start } 00:00:00+09` , ` ${ end } 00:00:00+09` ) ;
345329 } ) ;
346330
347331 it ( '빈 통계 목록 처리' , async ( ) => {
348- // Arrange
349332 postRepo . findPostByPostId . mockResolvedValue ( [ ] ) ;
350333
351- // Act
352334 const result = await postService . getPostByPostId ( 1 ) ;
353-
354- // Assert
355335 expect ( result ) . toEqual ( [ ] ) ;
356336 } ) ;
357337
358338 it ( '쿼리 오류 발생 시 예외를 그대로 전파' , async ( ) => {
359- // Arrange
360339 const errorMessage = '게시물 조회 중 문제가 발생했습니다.' ;
361340 postRepo . findPostByPostId . mockRejectedValue ( new DBError ( errorMessage ) ) ;
362341
363- // Act & Assert
364342 await expect ( postService . getPostByPostId ( 1 ) ) . rejects . toThrow ( errorMessage ) ;
365343 } ) ;
366344
367345 it ( '숫자가 아닌 ID를 전달해도 처리되어야 함' , async ( ) => {
368- // Arrange
369346 postRepo . findPostByPostId . mockResolvedValue ( mockPostStats ) ;
370-
371- // Act
372347 const result = await postService . getPostByPostId ( 'abc' as unknown as number ) ;
373-
374- // Assert
375348 expect ( result ) . toEqual ( expectedTransformedStats ) ;
376349 // Repository에 ID가 'abc'로 전달됨 (내부적으로 변환하지 않음)
377- expect ( postRepo . findPostByPostId ) . toHaveBeenCalledWith ( 'abc' , undefined , undefined ) ;
350+ expect ( postRepo . findPostByPostId ) . toHaveBeenCalledWith ( 'abc' , " undefined 00:00:00+09" , " undefined 00:00:00+09" ) ;
378351 } ) ;
352+
379353 } ) ;
380354
381355 describe ( 'getPostByPostUUID' , ( ) => {
@@ -416,39 +390,30 @@ describe('PostService', () => {
416390 } ) ;
417391
418392 it ( '게시물 UUID로 상세 통계 조회 (기본 7일 범위)' , async ( ) => {
419- // Arrange
420393 postRepo . findPostByPostUUID . mockResolvedValue ( mockPostStats ) ;
421394
422- // Act
423395 const result = await postService . getPostByPostUUID ( 'uuid-1234' ) ;
424396
425- // Assert
426397 expect ( result ) . toEqual ( expectedTransformedStats ) ;
427398 // 7일 범위 설정 확인 (현재 날짜 2025-03-15 기준)
428399 expect ( postRepo . findPostByPostUUID ) . toHaveBeenCalledWith (
429400 'uuid-1234' ,
430- '2025-03-09 ' , // 6일 전
431- '2025-03-15' // 오늘
432- ) ;
401+ '2025-03-15 ' , // 현재 날짜 (테스트에서 고정된 날짜)
402+ '2025-03-15' // 현재 날짜 (테스트에서 고정된 날짜)
403+ ) ;
433404 } ) ;
434405
435406 it ( '빈 통계 목록 처리' , async ( ) => {
436- // Arrange
437407 postRepo . findPostByPostUUID . mockResolvedValue ( [ ] ) ;
438-
439- // Act
440408 const result = await postService . getPostByPostUUID ( 'uuid-1234' ) ;
441409
442- // Assert
443410 expect ( result ) . toEqual ( [ ] ) ;
444411 } ) ;
445412
446413 it ( '쿼리 오류 발생 시 예외를 그대로 전파' , async ( ) => {
447- // Arrange
448414 const errorMessage = 'UUID로 게시물 조회 중 문제가 발생했습니다.' ;
449415 postRepo . findPostByPostUUID . mockRejectedValue ( new DBError ( errorMessage ) ) ;
450416
451- // Act & Assert
452417 await expect ( postService . getPostByPostUUID ( 'uuid-1234' ) ) . rejects . toThrow ( errorMessage ) ;
453418 } ) ;
454419
0 commit comments