@@ -213,11 +213,21 @@ describe("createUpsertLetterHandler", () => {
213213 test ( "processes all records successfully and returns no batch failures" , async ( ) => {
214214 const v2message = {
215215 letterEvent : createPreparedV2Event ( ) ,
216- supplierSpec : { supplierId : "supplier1" , specId : "spec1" , priority : 10 } ,
216+ supplierSpec : {
217+ supplierId : "supplier1" ,
218+ specId : "spec1" ,
219+ priority : 10 ,
220+ billingId : "billing1" ,
221+ } ,
217222 } ;
218223 const v1message = {
219224 letterEvent : createPreparedV1Event ( ) ,
220- supplierSpec : { supplierId : "supplier1" , specId : "spec1" , priority : 10 } ,
225+ supplierSpec : {
226+ supplierId : "supplier1" ,
227+ specId : "spec1" ,
228+ priority : 10 ,
229+ billingId : "billing1" ,
230+ } ,
221231 } ;
222232
223233 const evt : SQSEvent = createSQSEvent ( [
@@ -251,20 +261,20 @@ describe("createUpsertLetterHandler", () => {
251261 expect ( insertedV2Letter . status ) . toBe ( "PENDING" ) ;
252262 expect ( insertedV2Letter . groupId ) . toBe ( "client1campaign1template1" ) ;
253263 expect ( insertedV2Letter . source ) . toBe ( "/data-plane/letter-rendering/test" ) ;
254- expect ( insertedV2Letter . specificationBillingId ) . toBe ( "spec1 " ) ;
264+ expect ( insertedV2Letter . specificationBillingId ) . toBe ( "billing1 " ) ;
255265 expect ( insertedV2Letter . priority ) . toBe ( 10 ) ;
256266
257267 const insertedV1Letter = ( mockedDeps . letterRepo . putLetter as jest . Mock ) . mock
258268 . calls [ 1 ] [ 0 ] ;
259269 expect ( insertedV1Letter . id ) . toBe ( "letter1" ) ;
260- expect ( insertedV1Letter . supplierId ) . toBe ( "supplier1 " ) ;
261- expect ( insertedV1Letter . specificationId ) . toBe ( "spec1 " ) ;
262- expect ( insertedV1Letter . billingRef ) . toBe ( "spec1 " ) ;
270+ expect ( insertedV1Letter . supplierId ) . toBe ( "supplier2 " ) ;
271+ expect ( insertedV1Letter . specificationId ) . toBe ( "spec2 " ) ;
272+ expect ( insertedV1Letter . billingRef ) . toBe ( "spec2 " ) ;
263273 expect ( insertedV1Letter . url ) . toBe ( "s3://letterDataBucket/letter1.pdf" ) ;
264274 expect ( insertedV1Letter . status ) . toBe ( "PENDING" ) ;
265275 expect ( insertedV1Letter . groupId ) . toBe ( "client1campaign1template1" ) ;
266276 expect ( insertedV1Letter . source ) . toBe ( "/data-plane/letter-rendering/test" ) ;
267- expect ( insertedV1Letter . specificationBillingId ) . toBe ( "spec1 " ) ;
277+ expect ( insertedV1Letter . specificationBillingId ) . toBe ( "billing2 " ) ;
268278 expect ( insertedV1Letter . priority ) . toBe ( 10 ) ;
269279
270280 const updatedLetter = (
@@ -281,7 +291,12 @@ describe("createUpsertLetterHandler", () => {
281291 } ) ;
282292 expect ( mockMetrics . putMetric ) . toHaveBeenCalledWith (
283293 "MessagesProcessed" ,
284- 3 ,
294+ 2 ,
295+ "Count" ,
296+ ) ;
297+ expect ( mockMetrics . putMetric ) . toHaveBeenCalledWith (
298+ "MessagesProcessed" ,
299+ 1 ,
285300 "Count" ,
286301 ) ;
287302 } ) ;
@@ -478,14 +493,24 @@ describe("createUpsertLetterHandler", () => {
478493 id : "7b9a03ca-342a-4150-b56b-989109c45615" ,
479494 domainId : "ok" ,
480495 } ) ,
481- supplierSpec : { supplierId : "supplier1" , specId : "spec1" , priority : 10 } ,
496+ supplierSpec : {
497+ supplierId : "supplier1" ,
498+ specId : "spec1" ,
499+ priority : 10 ,
500+ billingId : "billing1" ,
501+ } ,
482502 } ;
483503 const message2 = {
484504 letterEvent : createPreparedV2Event ( {
485505 id : "7b9a03ca-342a-4150-b56b-989109c45616" ,
486506 domainId : "fail" ,
487507 } ) ,
488- supplierSpec : { supplierId : "supplier1" , specId : "spec1" , priority : 10 } ,
508+ supplierSpec : {
509+ supplierId : "supplier1" ,
510+ specId : "spec1" ,
511+ priority : 10 ,
512+ billingId : "billing1" ,
513+ } ,
489514 } ;
490515 const evt : SQSEvent = createSQSEvent ( [
491516 createSqsRecord ( "ok-msg" , JSON . stringify ( message1 ) ) ,
0 commit comments