@@ -2,32 +2,34 @@ import { LetterRepository } from "../../../../../internal/datastore/src/letter-r
22import { LetterStatusType } from "../../../../../internal/datastore/src/types" ;
33import { createLetter } from "../../helpers/create_letter_helpers" ;
44import { uploadFile } from "../../helpers/s3_helpers" ;
5- import { mockDeep } from ' jest-mock-extended' ;
5+ import { mockDeep } from " jest-mock-extended" ;
66
7- jest . mock ( '../../helpers/s3_helpers' )
8-
9- describe ( 'Create letter helpers' , ( ) => {
7+ jest . mock ( "../../helpers/s3_helpers" ) ;
108
9+ describe ( "Create letter helpers" , ( ) => {
1110 beforeEach ( ( ) => {
1211 jest . resetAllMocks ( ) ;
1312 } ) ;
1413
15- it ( 'create letter' , async ( ) => {
14+ it ( "create letter" , async ( ) => {
15+ jest . useFakeTimers ( ) ;
16+ jest . setSystemTime ( new Date ( 2020 , 1 , 1 ) ) ;
17+
1618 const mockPutLetter = jest . fn ( ) ;
1719 const mockedLetterRepository = {
18- putLetter : mockPutLetter
20+ putLetter : mockPutLetter ,
1921 } as any as LetterRepository ;
2022 const mockedUploadFile = uploadFile as jest . Mock ;
2123
22- const supplierId = ' supplierId' ;
23- const letterId = ' letterId' ;
24- const bucketName = ' bucketName' ;
25- const targetFilename = ' targetFilename' ;
26- const groupId = ' groupId' ;
27- const specificationId = ' specificationId' ;
28- const status = ' PENDING' as LetterStatusType ;
24+ const supplierId = " supplierId" ;
25+ const letterId = " letterId" ;
26+ const bucketName = " bucketName" ;
27+ const targetFilename = " targetFilename" ;
28+ const groupId = " groupId" ;
29+ const specificationId = " specificationId" ;
30+ const status = " PENDING" as LetterStatusType ;
2931
30- createLetter ( {
32+ await createLetter ( {
3133 letterId,
3234 bucketName,
3335 supplierId,
@@ -38,7 +40,21 @@ describe('Create letter helpers', () => {
3840 letterRepository : mockedLetterRepository ,
3941 } ) ;
4042
41- expect ( mockedUploadFile ) . toHaveBeenCalledWith ( 'bucketName' , 'supplierId' , '../../test_letter.pdf' , 'targetFilename' ) ;
42- //expect(mockPutLetter).toHaveBeenCalledWith({}); does not work
43+ expect ( mockedUploadFile ) . toHaveBeenCalledWith (
44+ "bucketName" ,
45+ "supplierId" ,
46+ "../../test_letter.pdf" ,
47+ "targetFilename" ,
48+ ) ;
49+ expect ( mockPutLetter ) . toHaveBeenCalledWith ( {
50+ createdAt : "2020-02-01T00:00:00.000Z" ,
51+ groupId : "groupId" ,
52+ id : "letterId" ,
53+ specificationId : "specificationId" ,
54+ status : "PENDING" ,
55+ supplierId : "supplierId" ,
56+ updatedAt : "2020-02-01T00:00:00.000Z" ,
57+ url : "s3://bucketName/supplierId/targetFilename" ,
58+ } ) ;
4359 } ) ;
4460} ) ;
0 commit comments