Skip to content

Commit

Permalink
Fix response objects returned on Customer functions (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
CassioMG authored Jun 24, 2024
1 parent 11895da commit b768607
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Sep12 {
if (!resp.data.id) {
throw new CustomerNotFoundError(params);
}
return resp;
return resp.data;
}

/**
Expand Down Expand Up @@ -104,7 +104,7 @@ export class Sep12 {
: this.headers,
},
);
return resp;
return resp.data;
}

/**
Expand Down Expand Up @@ -154,7 +154,7 @@ export class Sep12 {
: this.headers,
},
);
return resp;
return resp.data;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions @stellar/typescript-wallet-sdk/test/customer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ describe("Customer", () => {
type: customerType,
},
});
expect(resp.data.id).toBeTruthy();
const { id } = resp.data;
expect(resp.id).toBeTruthy();
const { id } = resp;

// Get
resp = await sep12.getCustomer({ id, type: customerType });
expect(Object.keys(resp.data).sort()).toEqual(
expect(Object.keys(resp).sort()).toEqual(
["id", "provided_fields", "fields", "status"].sort(),
);
expect(Object.keys(resp.data?.provided_fields).sort()).toEqual(
expect(Object.keys(resp?.provided_fields).sort()).toEqual(
["first_name", "last_name", "email_address"].sort(),
);
expect(Object.keys(resp.data?.fields).sort()).toEqual(
expect(Object.keys(resp?.fields).sort()).toEqual(
[
"bank_account_number",
"bank_number",
Expand All @@ -70,11 +70,11 @@ describe("Customer", () => {
},
id,
});
expect(resp.data.id).toBeTruthy();
expect(resp.id).toBeTruthy();

// Get again, check that the provided fields updated
resp = await sep12.getCustomer({ id, type: customerType });
expect(Object.keys(resp.data.fields).length).toBe(0);
expect(Object.keys(resp.fields).length).toBe(0);

// Delete
await sep12.delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe("Anchor Platform Integration Tests", () => {
bank_account_number: "12345",
},
});
expect(sep12Resp.data.id).toBeTruthy();
expect(sep12Resp.id).toBeTruthy();

// SEP-6 deposit
const sep6 = anchor.sep6();
Expand Down

0 comments on commit b768607

Please sign in to comment.