@@ -120,6 +120,43 @@ describe("letter-mapper", () => {
120120 } ) ;
121121 } ) ;
122122
123+ it ( "maps an internal Letter to a GetLetterResponse with sha256Hash when present" , ( ) => {
124+ const date = new Date ( ) . toISOString ( ) ;
125+ const letter : Letter = {
126+ id : "abc123" ,
127+ status : "PENDING" ,
128+ supplierId : "supplier1" ,
129+ specificationId : "spec123" ,
130+ billingRef : "spec123" ,
131+ groupId : "group123" ,
132+ url : "https://example.com/letter/abc123" ,
133+ createdAt : date ,
134+ updatedAt : date ,
135+ supplierStatus : "supplier1#PENDING" ,
136+ supplierStatusSk : date ,
137+ ttl : 123 ,
138+ sha256Hash : "abc123hash" ,
139+ source : "/data-plane/letter-rendering/pdf" ,
140+ subject : "letter-rendering/source/letter/letter-id" ,
141+ specificationBillingId : "billing123" ,
142+ } ;
143+
144+ const result : GetLetterResponse = mapToGetLetterResponse ( letter ) ;
145+
146+ expect ( result ) . toEqual ( {
147+ data : {
148+ id : "abc123" ,
149+ type : "Letter" ,
150+ attributes : {
151+ specificationId : "spec123" ,
152+ status : "PENDING" ,
153+ groupId : "group123" ,
154+ sha256Hash : "abc123hash" ,
155+ } ,
156+ } ,
157+ } ) ;
158+ } ) ;
159+
123160 it ( "maps an internal Letter to a GetLetterResponse with reasonCode and reasonText when present" , ( ) => {
124161 const date = new Date ( ) . toISOString ( ) ;
125162 const letter : Letter = {
@@ -209,4 +246,57 @@ describe("letter-mapper", () => {
209246 ] ,
210247 } ) ;
211248 } ) ;
249+ it ( "maps an internal Letter collection to a GetLettersResponse with sha256Hash when present" , ( ) => {
250+ const date = new Date ( ) . toISOString ( ) ;
251+ const letter : Letter = {
252+ id : "abc123" ,
253+ status : "PENDING" ,
254+ supplierId : "supplier1" ,
255+ specificationId : "spec123" ,
256+ billingRef : "spec123" ,
257+ groupId : "group123" ,
258+ url : "https://example.com/letter/abc123" ,
259+ createdAt : date ,
260+ updatedAt : date ,
261+ supplierStatus : "supplier1#PENDING" ,
262+ supplierStatusSk : date ,
263+ ttl : 123 ,
264+ reasonCode : "R01" ,
265+ reasonText : "Reason text" ,
266+ sha256Hash : "abc123hash" ,
267+ source : "/data-plane/letter-rendering/pdf" ,
268+ subject : "letter-rendering/source/letter/letter-id" ,
269+ specificationBillingId : "billing123" ,
270+ } ;
271+
272+ const result : GetLettersResponse = mapToGetLettersResponse ( [
273+ letter ,
274+ letter ,
275+ ] ) ;
276+
277+ expect ( result ) . toEqual ( {
278+ data : [
279+ {
280+ id : "abc123" ,
281+ type : "Letter" ,
282+ attributes : {
283+ specificationId : "spec123" ,
284+ status : "PENDING" ,
285+ groupId : "group123" ,
286+ sha256Hash : "abc123hash" ,
287+ } ,
288+ } ,
289+ {
290+ id : "abc123" ,
291+ type : "Letter" ,
292+ attributes : {
293+ specificationId : "spec123" ,
294+ status : "PENDING" ,
295+ groupId : "group123" ,
296+ sha256Hash : "abc123hash" ,
297+ } ,
298+ } ,
299+ ] ,
300+ } ) ;
301+ } ) ;
212302} ) ;
0 commit comments