Skip to content

Commit b5c8c25

Browse files
committed
fix: add data property to CreatePixQrCodeResponse error type and add test for default metadata
1 parent 501eee8 commit b5c8c25

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ export type PixIdParams = {
454454
export type CreatePixQrCodeResponse =
455455
| {
456456
error: string;
457+
data: null;
457458
}
458459
| {
459460
error: null;

test/index.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,24 @@ describe("AbacatePay", () => {
233233
);
234234
expect(result).toEqual({ data: "pix-qrcode-payment-simulated" });
235235
});
236+
237+
it("should have simulatePayment method that uses empty object as default metadata", async () => {
238+
const sdk = AbacatePay(apiKey);
239+
const pixQrCodeData = { id: "pix_char_abc123" };
240+
241+
mockRequest.mockResolvedValue({ data: "pix-qrcode-payment-simulated" });
242+
243+
const result = await sdk.pixQrCode.simulatePayment(pixQrCodeData);
244+
245+
expect(mockRequest).toHaveBeenCalledWith(
246+
"/pixQrCode/simulate-payment?id=pix_char_abc123",
247+
{
248+
method: "POST",
249+
body: JSON.stringify({ metadata: {} }),
250+
},
251+
);
252+
expect(result).toEqual({ data: "pix-qrcode-payment-simulated" });
253+
});
236254
});
237255

238256
describe("withdrawal", () => {

0 commit comments

Comments
 (0)