@@ -67,6 +67,51 @@ describe("transaction", () => {
6767 expect ( castedData . resource . description ) . to . equal ( mockResponseBody . description ) ;
6868 } ) ;
6969
70+ it ( "get returns an error response on failure" , async ( ) => {
71+ const mockGetResponse = {
72+ status : 401 ,
73+ error : "An error occurred"
74+ } ;
75+
76+ const mockRequest = sinon . stub ( requestClient , "httpGet" ) . resolves ( mockGetResponse ) ;
77+ const transaction : TransactionService = new TransactionService ( requestClient ) ;
78+ const data = await transaction . getTransaction ( { } as string ) ;
79+
80+ expect ( data . httpStatusCode ) . to . equal ( 401 ) ;
81+ const castedData : ApiErrorResponse = data ;
82+ expect ( castedData . errors [ 0 ] ) . to . equal ( "An error occurred" ) ;
83+ } ) ;
84+
85+ it ( "get maps the company field data items correctly" , async ( ) => {
86+ const mockResponseBody : TransactionResource = ( {
87+ id : "12345678" ,
88+ company_name : "HELLO LTD" ,
89+ company_number : "88" ,
90+ links : {
91+ self : "/self"
92+ } ,
93+ reference : "ref" ,
94+ description : "desc"
95+ } ) ;
96+
97+ const mockGetResponse = {
98+ status : 200 ,
99+ body : mockResponseBody
100+ } ;
101+
102+ const mockRequest = sinon . stub ( requestClient , "httpGet" ) . resolves ( mockGetResponse ) ;
103+ const transaction : TransactionService = new TransactionService ( requestClient ) ;
104+ const data = await transaction . getTransaction ( { } as string ) ;
105+
106+ expect ( data . httpStatusCode ) . to . equal ( 200 ) ;
107+ const castedData : Resource < Transaction > = data as Resource < Transaction > ;
108+ expect ( castedData . resource . companyName ) . to . equal ( mockResponseBody . company_name ) ;
109+ expect ( castedData . resource . companyNumber ) . to . equal ( mockResponseBody . company_number ) ;
110+ expect ( castedData . resource . links . self ) . to . equal ( mockResponseBody . links . self ) ;
111+ expect ( castedData . resource . reference ) . to . equal ( mockResponseBody . reference ) ;
112+ expect ( castedData . resource . description ) . to . equal ( mockResponseBody . description ) ;
113+ } ) ;
114+
70115 it ( "put returns successful response" , async ( ) => {
71116 const mockResponseBody : TransactionResource = ( {
72117 id : "12345678" ,
0 commit comments