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.ts82
1 files changed, 19 insertions, 63 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/order.test.ts b/packages/merchant-backoffice-ui/src/hooks/order.test.ts
index aa67743df..c243309a8 100644
--- a/packages/merchant-backoffice-ui/src/hooks/order.test.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/order.test.ts
@@ -38,16 +38,9 @@ describe("order api interaction with listing", () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [{ order_id: "1" } as MerchantBackend.Orders.OrderHistoryEntry],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
response: {
- orders: [{ order_id: "2" } as MerchantBackend.Orders.OrderHistoryEntry],
+ orders: [{ order_id: "1" }, { order_id: "2" } as MerchantBackend.Orders.OrderHistoryEntry],
},
});
@@ -85,16 +78,9 @@ describe("order api interaction with listing", () => {
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [{ order_id: "1" } as any],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
response: {
- orders: [{ order_id: "2" } as any, { order_id: "3" } as any],
+ orders: [{ order_id: "1" }, { order_id: "2" } as any, { order_id: "3" } as any],
},
});
@@ -125,21 +111,12 @@ describe("order api interaction with listing", () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [
- {
- order_id: "1",
- amount: "EUR:12",
- refundable: true,
- } as MerchantBackend.Orders.OrderHistoryEntry,
- ],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
- response: { orders: [] },
+ response: { orders: [{
+ order_id: "1",
+ amount: "EUR:12",
+ refundable: true,
+ } as MerchantBackend.Orders.OrderHistoryEntry] },
});
const newDate = (d: Date) => {
@@ -182,17 +159,10 @@ describe("order api interaction with listing", () => {
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [
- { order_id: "1", amount: "EUR:12", refundable: false } as any,
- ],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
- response: { orders: [] },
+ response: { orders: [
+ { order_id: "1", amount: "EUR:12", refundable: false } as any,
+ ] },
});
api.refundOrder("1", {
@@ -230,16 +200,9 @@ describe("order api interaction with listing", () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [{ order_id: "1" } as MerchantBackend.Orders.OrderHistoryEntry],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
response: {
- orders: [{ order_id: "2" } as MerchantBackend.Orders.OrderHistoryEntry],
+ orders: [{ order_id: "1" }, { order_id: "2" } as MerchantBackend.Orders.OrderHistoryEntry],
},
});
@@ -272,13 +235,6 @@ describe("order api interaction with listing", () => {
env.addRequestExpectation(API_DELETE_ORDER("1"), {});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 0, paid: "yes" },
- response: {
- orders: [],
- },
- });
-
- env.addRequestExpectation(API_LIST_ORDERS, {
qparam: { delta: -20, paid: "yes" },
response: {
orders: [{ order_id: "2" } as any],
@@ -459,14 +415,14 @@ describe("order listing pagination", () => {
it("should not load more if has reach the end", async () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 20, wired: "yes", date_ms: 12 },
+ qparam: { delta: 20, wired: "yes", date_s: 12 },
response: {
orders: [{ order_id: "1" } as any],
},
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: -20, wired: "yes", date_ms: 13 },
+ qparam: { delta: -20, wired: "yes", date_s: 13 },
response: {
orders: [{ order_id: "2" } as any],
},
@@ -478,7 +434,7 @@ describe("order listing pagination", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
- const date = new Date(12);
+ const date = new Date(12000);
const query = useInstanceOrders({ wired: "yes", date }, newDate);
const api = useOrderAPI();
return { query, api };
@@ -525,14 +481,14 @@ describe("order listing pagination", () => {
const ordersFrom20to0 = [...ordersFrom0to20].reverse();
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 20, wired: "yes", date_ms: 12 },
+ qparam: { delta: 20, wired: "yes", date_s: 12 },
response: {
orders: ordersFrom0to20,
},
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: -20, wired: "yes", date_ms: 13 },
+ qparam: { delta: -20, wired: "yes", date_s: 13 },
response: {
orders: ordersFrom20to40,
},
@@ -544,7 +500,7 @@ describe("order listing pagination", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
- const date = new Date(12);
+ const date = new Date(12000);
const query = useInstanceOrders({ wired: "yes", date }, newDate);
const api = useOrderAPI();
return { query, api };
@@ -568,7 +524,7 @@ describe("order listing pagination", () => {
expect(query.isReachingStart).false;
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: -40, wired: "yes", date_ms: 13 },
+ qparam: { delta: -40, wired: "yes", date_s: 13 },
response: {
orders: [...ordersFrom20to40, { order_id: "41" }],
},
@@ -595,7 +551,7 @@ describe("order listing pagination", () => {
});
env.addRequestExpectation(API_LIST_ORDERS, {
- qparam: { delta: 40, wired: "yes", date_ms: 12 },
+ qparam: { delta: 40, wired: "yes", date_s: 12 },
response: {
orders: [...ordersFrom0to20, { order_id: "-1" }],
},