@@ -157,59 +157,37 @@ describe("transaction", () => {
157157 expect ( castedData . errors ?. [ 0 ] ) . to . equal ( "Unprocessable Entity" ) ;
158158 } ) ;
159159
160- it ( "getTransactionsForResourceKind returns a transaction list with mapped filings" , async ( ) => {
161- const mockResponseBody = {
162- items : [
163- {
164- id : "txn1" ,
165- updated_at : "2024-06-25T12:00:00Z" ,
166- status : "closed" ,
167- filings : {
160+ it ( "get transaction list for resource kind returns success response " , async ( ) => {
161+ const itemsArray : TransactionData [ ] = ( [
162+ {
163+ id : "123" ,
164+ status : "closed" ,
165+ filings : {
166+ testFiling : {
168167 status : "accepted" ,
169- company_number : "AP000042" ,
168+ companyNumber : "AP000042" ,
170169 type : "acsp"
171- } ,
172- resume_journey_uri : "/resume/txn1"
170+ } as Filing
173171 }
174- ]
175- } ;
172+ }
173+ ] ) ;
174+
175+ const transactionList : TransactionList = ( {
176+ items : itemsArray
177+ } ) ;
176178
177179 const mockGetResponse = {
178180 status : 200 ,
179- body : mockResponseBody
181+ body : transactionList
180182 } ;
181183
182- sinon . stub ( requestClient , "httpGet" ) . resolves ( mockGetResponse ) ;
183- const transaction : TransactionService = new TransactionService ( requestClient ) ;
184- const data = await transaction . getTransactionsForResourceKind ( "req-123" , "some-kind" ) ;
185-
184+ const mockRequest = sinon . stub ( requestClient , "httpGet" ) . resolves ( mockGetResponse ) ;
185+ const transaction : TransactionService = new TransactionService ( requestClient ) ;
186+ const data = await transaction . getTransactionsForResourceKind ( { } as string ) ;
186187 expect ( data . httpStatusCode ) . to . equal ( 200 ) ;
187188 const castedData : Resource < TransactionList > = data as Resource < TransactionList > ;
188- expect ( castedData . resource ?. items ) . to . have . lengthOf ( 1 ) ;
189- const item = castedData . resource ?. items [ 0 ] ;
190- expect ( item ?. id ) . to . equal ( "txn1" ) ;
191- expect ( item ?. updatedAt ) . to . equal ( "2024-06-25T12:00:00Z" ) ;
192- expect ( item ?. status ) . to . equal ( "closed" ) ;
193- expect ( item ?. filings ) . to . deep . equal ( {
194- status : "accepted" ,
195- companyNumber : "AP000042" ,
196- type : "acsp"
197- } ) ;
198- expect ( item ?. resumeJourneyUri ) . to . equal ( "/resume/txn1" ) ;
199- } ) ;
200-
201- it ( "getTransactionsForResourceKind returns error response on failure" , async ( ) => {
202- const mockGetResponse = {
203- status : 500 ,
204- error : "Internal Server Error"
205- } ;
206-
207- sinon . stub ( requestClient , "httpGet" ) . resolves ( mockGetResponse ) ;
208- const transaction : TransactionService = new TransactionService ( requestClient ) ;
209- const data = await transaction . getTransactionsForResourceKind ( "req-123" , "some-kind" ) ;
210-
211- expect ( data . httpStatusCode ) . to . equal ( 500 ) ;
212- const castedData : ApiErrorResponse = data as ApiErrorResponse ;
213- expect ( castedData . errors [ 0 ] ) . to . equal ( "Internal Server Error" ) ;
189+ expect ( castedData . resource ?. items [ 0 ] . id ) . to . equal ( transactionList . items [ 0 ] . id ) ;
190+ expect ( castedData . resource ?. items [ 0 ] . status ) . to . equal ( transactionList . items [ 0 ] . status ) ;
191+ expect ( castedData . resource ?. items [ 0 ] . filings ) . to . equal ( transactionList . items [ 0 ] . filings ) ;
214192 } ) ;
215193} ) ;
0 commit comments