aboutsummaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/hooks/order.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/order.test.ts')
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/order.test.ts37
1 files changed, 19 insertions, 18 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/order.test.ts b/packages/merchant-backoffice-ui/src/hooks/order.test.ts
index 0d4199875..3d4f2809f 100644
--- a/packages/merchant-backoffice-ui/src/hooks/order.test.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/order.test.ts
@@ -22,7 +22,7 @@
import { AmountString, TalerMerchantApi } from "@gnu-taler/taler-util";
import * as tests from "@gnu-taler/web-util/testing";
import { expect } from "chai";
-import { useInstanceOrders, useOrderAPI, useOrderDetails } from "./order.js";
+import { useInstanceOrders, useOrderDetails } from "./order.js";
import { ApiMockEnvironment } from "./testing.js";
import {
API_CREATE_ORDER,
@@ -32,6 +32,7 @@ import {
API_LIST_ORDERS,
API_REFUND_ORDER_BY_ID,
} from "./urls.js";
+import { useMerchantApiContext } from "@gnu-taler/web-util/browser";
describe("order api interaction with listing", () => {
it("should evict cache when creating an order", async () => {
@@ -51,7 +52,7 @@ describe("order api interaction with listing", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
const query = useInstanceOrders({ paid: "yes" }, newDate);
- const api = useOrderAPI();
+ const { lib: api } = useMerchantApiContext()
return { query, api };
},
{},
@@ -85,9 +86,9 @@ describe("order api interaction with listing", () => {
},
});
- api.createOrder({
- order: { amount: "ARS:12", summary: "pay me" },
- } as any);
+ api.management.createOrder(undefined, {
+ order: { amount: "ARS:12" as AmountString, summary: "pay me" },
+ })
},
({ query, api }) => {
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
@@ -129,7 +130,7 @@ describe("order api interaction with listing", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
const query = useInstanceOrders({ paid: "yes" }, newDate);
- const api = useOrderAPI();
+ const { lib: api } = useMerchantApiContext()
return { query, api };
},
{},
@@ -170,10 +171,10 @@ describe("order api interaction with listing", () => {
},
});
- api.refundOrder("1", {
+ api.management.addRefund(undefined, "1", {
reason: "double pay",
refund: "EUR:1" as AmountString,
- });
+ })
},
({ query, api }) => {
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
@@ -218,7 +219,7 @@ describe("order api interaction with listing", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
const query = useInstanceOrders({ paid: "yes" }, newDate);
- const api = useOrderAPI();
+ const { lib: api } = useMerchantApiContext()
return { query, api };
},
{},
@@ -246,7 +247,7 @@ describe("order api interaction with listing", () => {
},
});
- api.deleteOrder("1");
+ api.management.deleteOrder(undefined, "1")
},
({ query, api }) => {
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
@@ -286,7 +287,7 @@ describe("order api interaction with details", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
const query = useOrderDetails("1");
- const api = useOrderAPI();
+ const { lib: api } = useMerchantApiContext()
return { query, api };
},
{},
@@ -319,10 +320,10 @@ describe("order api interaction with details", () => {
} as unknown as TalerMerchantApi.CheckPaymentPaidResponse,
});
- api.refundOrder("1", {
+ api.management.addRefund(undefined, "1", {
reason: "double pay",
refund: "EUR:1" as AmountString,
- });
+ })
},
({ query, api }) => {
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
@@ -362,7 +363,7 @@ describe("order api interaction with details", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
const query = useOrderDetails("1");
- const api = useOrderAPI();
+ const { lib: api } = useMerchantApiContext()
return { query, api };
},
{},
@@ -393,9 +394,9 @@ describe("order api interaction with details", () => {
} as unknown as TalerMerchantApi.CheckPaymentPaidResponse,
});
- api.forgetOrder("1", {
+ api.management.forgetOrder(undefined, "1", {
fields: ["$.summary"],
- });
+ })
},
({ query, api }) => {
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
@@ -441,7 +442,7 @@ describe("order listing pagination", () => {
() => {
const date = new Date(12000);
const query = useInstanceOrders({ wired: "yes", date }, newDate);
- const api = useOrderAPI();
+ const { lib: api } = useMerchantApiContext()
return { query, api };
},
{},
@@ -507,7 +508,7 @@ describe("order listing pagination", () => {
() => {
const date = new Date(12000);
const query = useInstanceOrders({ wired: "yes", date }, newDate);
- const api = useOrderAPI();
+ const { lib: api } = useMerchantApiContext()
return { query, api };
},
{},