@@ -153,59 +153,37 @@ describe("transaction", () => {
153153 expect ( castedData . errors [ 0 ] ) . to . equal ( "Unprocessable Entity" ) ;
154154 } ) ;
155155
156- it ( "getTransactionsForResourceKind returns a transaction list with mapped filings" , async ( ) => {
157- const mockResponseBody = {
158- items : [
159- {
160- id : "txn1" ,
161- updated_at : "2024-06-25T12:00:00Z" ,
162- status : "closed" ,
163- filings : {
156+ it ( "get transaction list for resource kind returns success response " , async ( ) => {
157+ const itemsArray : TransactionData [ ] = ( [
158+ {
159+ id : "123" ,
160+ status : "closed" ,
161+ filings : {
162+ testFiling : {
164163 status : "accepted" ,
165- company_number : "AP000042" ,
164+ companyNumber : "AP000042" ,
166165 type : "acsp"
167- } ,
168- resume_journey_uri : "/resume/txn1"
166+ } as Filing
169167 }
170- ]
171- } ;
168+ }
169+ ] ) ;
170+
171+ const transactionList : TransactionList = ( {
172+ items : itemsArray
173+ } ) ;
172174
173175 const mockGetResponse = {
174176 status : 200 ,
175- body : mockResponseBody
177+ body : transactionList
176178 } ;
177179
178- sinon . stub ( requestClient , "httpGet" ) . resolves ( mockGetResponse ) ;
179- const transaction : TransactionService = new TransactionService ( requestClient ) ;
180- const data = await transaction . getTransactionsForResourceKind ( "req-123" , "some-kind" ) ;
181-
180+ const mockRequest = sinon . stub ( requestClient , "httpGet" ) . resolves ( mockGetResponse ) ;
181+ const transaction : TransactionService = new TransactionService ( requestClient ) ;
182+ const data = await transaction . getTransactionsForResourceKind ( { } as string ) ;
182183 expect ( data . httpStatusCode ) . to . equal ( 200 ) ;
183184 const castedData : Resource < TransactionList > = data as Resource < TransactionList > ;
184- expect ( castedData . resource ?. items ) . to . have . lengthOf ( 1 ) ;
185- const item = castedData . resource ?. items [ 0 ] ;
186- expect ( item ?. id ) . to . equal ( "txn1" ) ;
187- expect ( item ?. updatedAt ) . to . equal ( "2024-06-25T12:00:00Z" ) ;
188- expect ( item ?. status ) . to . equal ( "closed" ) ;
189- expect ( item ?. filings ) . to . deep . equal ( {
190- status : "accepted" ,
191- companyNumber : "AP000042" ,
192- type : "acsp"
193- } ) ;
194- expect ( item ?. resumeJourneyUri ) . to . equal ( "/resume/txn1" ) ;
195- } ) ;
196-
197- it ( "getTransactionsForResourceKind returns error response on failure" , async ( ) => {
198- const mockGetResponse = {
199- status : 500 ,
200- error : "Internal Server Error"
201- } ;
202-
203- sinon . stub ( requestClient , "httpGet" ) . resolves ( mockGetResponse ) ;
204- const transaction : TransactionService = new TransactionService ( requestClient ) ;
205- const data = await transaction . getTransactionsForResourceKind ( "req-123" , "some-kind" ) ;
206-
207- expect ( data . httpStatusCode ) . to . equal ( 500 ) ;
208- const castedData : ApiErrorResponse = data as ApiErrorResponse ;
209- expect ( castedData . errors [ 0 ] ) . to . equal ( "Internal Server Error" ) ;
185+ expect ( castedData . resource ?. items [ 0 ] . id ) . to . equal ( transactionList . items [ 0 ] . id ) ;
186+ expect ( castedData . resource ?. items [ 0 ] . status ) . to . equal ( transactionList . items [ 0 ] . status ) ;
187+ expect ( castedData . resource ?. items [ 0 ] . filings ) . to . equal ( transactionList . items [ 0 ] . filings ) ;
210188 } ) ;
211189} ) ;
0 commit comments