@@ -4,6 +4,8 @@ import sinon from "sinon";
44import TransactionService from "../../../src/services/transaction/service" ;
55import { RequestClient } from "../../../src/http" ;
66import { Transaction , TransactionResource } from "../../../src/services/transaction" ;
7+ import { ApiErrorResponse } from "../../../src/services/resource" ;
8+ import { Resource } from "../../../src" ;
79const expect = chai . expect ;
810
911const requestClient = new RequestClient ( { baseUrl : "URL-NOT-USED" , oauthToken : "TOKEN-NOT-USED" } ) ;
@@ -31,7 +33,8 @@ describe("transaction", () => {
3133 const data = await transaction . postTransaction ( { } as Transaction ) ;
3234
3335 expect ( data . httpStatusCode ) . to . equal ( 401 ) ;
34- expect ( data . resource ) . to . be . undefined ;
36+ const castedData : ApiErrorResponse = data ;
37+ expect ( castedData . errors [ 0 ] ) . to . equal ( "An error occurred" ) ;
3538 } ) ;
3639
3740 it ( "maps the company field data items correctly" , async ( ) => {
@@ -56,10 +59,11 @@ describe("transaction", () => {
5659 const data = await transaction . postTransaction ( { } as Transaction ) ;
5760
5861 expect ( data . httpStatusCode ) . to . equal ( 200 ) ;
59- expect ( data . resource . companyName ) . to . equal ( mockResponseBody . company_name ) ;
60- expect ( data . resource . companyNumber ) . to . equal ( mockResponseBody . company_number ) ;
61- expect ( data . resource . links . self ) . to . equal ( mockResponseBody . links . self ) ;
62- expect ( data . resource . reference ) . to . equal ( mockResponseBody . reference ) ;
63- expect ( data . resource . description ) . to . equal ( mockResponseBody . description ) ;
62+ const castedData : Resource < Transaction > = data as Resource < Transaction > ;
63+ expect ( castedData . resource . companyName ) . to . equal ( mockResponseBody . company_name ) ;
64+ expect ( castedData . resource . companyNumber ) . to . equal ( mockResponseBody . company_number ) ;
65+ expect ( castedData . resource . links . self ) . to . equal ( mockResponseBody . links . self ) ;
66+ expect ( castedData . resource . reference ) . to . equal ( mockResponseBody . reference ) ;
67+ expect ( castedData . resource . description ) . to . equal ( mockResponseBody . description ) ;
6468 } ) ;
6569} ) ;
0 commit comments