@@ -14,15 +14,25 @@ function createSqsRecord(
1414
1515function createSupplierConfig ( overrides : Record < string , any > = { } ) {
1616 return {
17- id : "supplier-123 " ,
18- name : "Supplier supplier-123 " ,
17+ id : "supplier-1 " ,
18+ name : "Supplier 1 " ,
1919 channelType : "LETTER" ,
2020 dailyCapacity : 2000 ,
2121 status : "PROD" ,
2222 ...overrides ,
2323 } ;
2424}
2525
26+ function createSupplierPackConfig ( ) {
27+ return {
28+ id : "supplier1-client1-campaign" ,
29+ packSpecificationId : "client-1-campaign" ,
30+ supplierId : "supplier1" ,
31+ approval : "APPROVED" ,
32+ status : "PROD" ,
33+ } ;
34+ }
35+
2636describe ( "supplierConfigHandler" , ( ) => {
2737 let mockDeps : Deps ;
2838 let handler : ReturnType < typeof createSupplierConfigIngressHandler > ;
@@ -110,6 +120,22 @@ describe("supplierConfigHandler", () => {
110120 ) . not . toHaveBeenCalled ( ) ;
111121 } ) ;
112122
123+ it ( "accepts a type field ending in a status and version" , async ( ) => {
124+ const data = createSupplierPackConfig ( ) ;
125+ const record = createSqsRecord (
126+ data ,
127+ "uk.nhs.notify.supplier-config.supplier-pack.prod.v1" ,
128+ ) ;
129+ const event = { Records : [ record ] } as unknown as SQSEvent ;
130+
131+ const result = await handler ( event ) ;
132+
133+ expect ( result ) . toEqual ( { batchItemFailures : [ ] } ) ;
134+ expect (
135+ mockDeps . supplierConfigRepo . upsertSupplierConfig ,
136+ ) . toHaveBeenCalledWith ( "supplier-pack" , data ) ;
137+ } ) ;
138+
113139 it ( "rejects an entity not matching the appropriate schema" , async ( ) => {
114140 const invalidData = createSupplierConfig ( { dailyCapacity : undefined } ) ;
115141 const record = createSqsRecord ( invalidData ) ;
0 commit comments