summaryrefslogtreecommitdiff
path: root/packages/merchant-backoffice-ui/src/hooks/reserve.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/reserve.test.ts')
-rw-r--r--packages/merchant-backoffice-ui/src/hooks/reserve.test.ts114
1 files changed, 57 insertions, 57 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/reserve.test.ts b/packages/merchant-backoffice-ui/src/hooks/reserve.test.ts
index d2831ecff..b3eecd754 100644
--- a/packages/merchant-backoffice-ui/src/hooks/reserve.test.ts
+++ b/packages/merchant-backoffice-ui/src/hooks/reserve.test.ts
@@ -25,16 +25,16 @@ import {
useInstanceReserves,
useReserveDetails,
useReservesAPI,
- useTipDetails,
+ useRewardDetails,
} from "./reserves.js";
import { ApiMockEnvironment } from "./testing.js";
import {
- API_AUTHORIZE_TIP,
- API_AUTHORIZE_TIP_FOR_RESERVE,
+ API_AUTHORIZE_REWARD,
+ API_AUTHORIZE_REWARD_FOR_RESERVE,
API_CREATE_RESERVE,
API_DELETE_RESERVE,
API_GET_RESERVE_BY_ID,
- API_GET_TIP_BY_ID,
+ API_GET_REWARD_BY_ID,
API_LIST_RESERVES,
} from "./urls.js";
import * as tests from "@gnu-taler/web-util/testing";
@@ -48,7 +48,7 @@ describe("reserve api interaction with listing", () => {
reserves: [
{
reserve_pub: "11",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
],
},
});
@@ -89,10 +89,10 @@ describe("reserve api interaction with listing", () => {
reserves: [
{
reserve_pub: "11",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
{
reserve_pub: "22",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
],
},
});
@@ -115,10 +115,10 @@ describe("reserve api interaction with listing", () => {
reserves: [
{
reserve_pub: "11",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
{
reserve_pub: "22",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
],
});
},
@@ -138,13 +138,13 @@ describe("reserve api interaction with listing", () => {
reserves: [
{
reserve_pub: "11",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
{
reserve_pub: "22",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
{
reserve_pub: "33",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
],
},
});
@@ -182,10 +182,10 @@ describe("reserve api interaction with listing", () => {
reserves: [
{
reserve_pub: "22",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
{
reserve_pub: "33",
- } as MerchantBackend.Tips.ReserveStatusEntry,
+ } as MerchantBackend.Rewards.ReserveStatusEntry,
],
},
});
@@ -213,16 +213,16 @@ describe("reserve api interaction with listing", () => {
});
describe("reserve api interaction with details", () => {
- it("should evict cache when adding a tip for a specific reserve", async () => {
+ it("should evict cache when adding a reward for a specific reserve", async () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_GET_RESERVE_BY_ID("11"), {
response: {
accounts: [{ payto_uri: "payto://here" }],
- tips: [{ reason: "why?", tip_id: "id1", total_amount: "USD:10" }],
- } as MerchantBackend.Tips.ReserveDetail,
+ rewards: [{ reason: "why?", reward_id: "id1", total_amount: "USD:10" }],
+ } as MerchantBackend.Rewards.ReserveDetail,
qparam: {
- tips: "yes",
+ rewards: "yes",
},
});
@@ -246,37 +246,37 @@ describe("reserve api interaction with details", () => {
if (!query.ok) return;
expect(query.data).deep.equals({
accounts: [{ payto_uri: "payto://here" }],
- tips: [{ reason: "why?", tip_id: "id1", total_amount: "USD:10" }],
+ rewards: [{ reason: "why?", reward_id: "id1", total_amount: "USD:10" }],
});
- env.addRequestExpectation(API_AUTHORIZE_TIP_FOR_RESERVE("11"), {
+ env.addRequestExpectation(API_AUTHORIZE_REWARD_FOR_RESERVE("11"), {
request: {
amount: "USD:12",
justification: "not",
next_url: "http://taler.net",
},
response: {
- tip_id: "id2",
- taler_tip_uri: "uri",
- tip_expiration: { t_s: 1 },
- tip_status_url: "url",
+ reward_id: "id2",
+ taler_reward_uri: "uri",
+ reward_expiration: { t_s: 1 },
+ reward_status_url: "url",
},
});
env.addRequestExpectation(API_GET_RESERVE_BY_ID("11"), {
response: {
accounts: [{ payto_uri: "payto://here" }],
- tips: [
- { reason: "why?", tip_id: "id1", total_amount: "USD:10" },
- { reason: "not", tip_id: "id2", total_amount: "USD:12" },
+ rewards: [
+ { reason: "why?", reward_id: "id1", total_amount: "USD:10" },
+ { reason: "not", reward_id: "id2", total_amount: "USD:12" },
],
- } as MerchantBackend.Tips.ReserveDetail,
+ } as MerchantBackend.Rewards.ReserveDetail,
qparam: {
- tips: "yes",
+ rewards: "yes",
},
});
- api.authorizeTipReserve("11", {
+ api.authorizeRewardReserve("11", {
amount: "USD:12",
justification: "not",
next_url: "http://taler.net",
@@ -294,9 +294,9 @@ describe("reserve api interaction with details", () => {
expect(query.data).deep.equals({
accounts: [{ payto_uri: "payto://here" }],
- tips: [
- { reason: "why?", tip_id: "id1", total_amount: "USD:10" },
- { reason: "not", tip_id: "id2", total_amount: "USD:12" },
+ rewards: [
+ { reason: "why?", reward_id: "id1", total_amount: "USD:10" },
+ { reason: "not", reward_id: "id2", total_amount: "USD:12" },
],
});
},
@@ -308,16 +308,16 @@ describe("reserve api interaction with details", () => {
expect(env.assertJustExpectedRequestWereMade()).deep.eq({ result: "ok" });
});
- it("should evict cache when adding a tip for a random reserve", async () => {
+ it("should evict cache when adding a reward for a random reserve", async () => {
const env = new ApiMockEnvironment();
env.addRequestExpectation(API_GET_RESERVE_BY_ID("11"), {
response: {
accounts: [{ payto_uri: "payto://here" }],
- tips: [{ reason: "why?", tip_id: "id1", total_amount: "USD:10" }],
- } as MerchantBackend.Tips.ReserveDetail,
+ rewards: [{ reason: "why?", reward_id: "id1", total_amount: "USD:10" }],
+ } as MerchantBackend.Rewards.ReserveDetail,
qparam: {
- tips: "yes",
+ rewards: "yes",
},
});
@@ -341,37 +341,37 @@ describe("reserve api interaction with details", () => {
if (!query.ok) return;
expect(query.data).deep.equals({
accounts: [{ payto_uri: "payto://here" }],
- tips: [{ reason: "why?", tip_id: "id1", total_amount: "USD:10" }],
+ rewards: [{ reason: "why?", reward_id: "id1", total_amount: "USD:10" }],
});
- env.addRequestExpectation(API_AUTHORIZE_TIP, {
+ env.addRequestExpectation(API_AUTHORIZE_REWARD, {
request: {
amount: "USD:12",
justification: "not",
next_url: "http://taler.net",
},
response: {
- tip_id: "id2",
- taler_tip_uri: "uri",
- tip_expiration: { t_s: 1 },
- tip_status_url: "url",
+ reward_id: "id2",
+ taler_reward_uri: "uri",
+ reward_expiration: { t_s: 1 },
+ reward_status_url: "url",
},
});
env.addRequestExpectation(API_GET_RESERVE_BY_ID("11"), {
response: {
accounts: [{ payto_uri: "payto://here" }],
- tips: [
- { reason: "why?", tip_id: "id1", total_amount: "USD:10" },
- { reason: "not", tip_id: "id2", total_amount: "USD:12" },
+ rewards: [
+ { reason: "why?", reward_id: "id1", total_amount: "USD:10" },
+ { reason: "not", reward_id: "id2", total_amount: "USD:12" },
],
- } as MerchantBackend.Tips.ReserveDetail,
+ } as MerchantBackend.Rewards.ReserveDetail,
qparam: {
- tips: "yes",
+ rewards: "yes",
},
});
- api.authorizeTip({
+ api.authorizeReward({
amount: "USD:12",
justification: "not",
next_url: "http://taler.net",
@@ -387,9 +387,9 @@ describe("reserve api interaction with details", () => {
expect(query.data).deep.equals({
accounts: [{ payto_uri: "payto://here" }],
- tips: [
- { reason: "why?", tip_id: "id1", total_amount: "USD:10" },
- { reason: "not", tip_id: "id2", total_amount: "USD:12" },
+ rewards: [
+ { reason: "why?", reward_id: "id1", total_amount: "USD:10" },
+ { reason: "not", reward_id: "id2", total_amount: "USD:12" },
],
});
},
@@ -402,15 +402,15 @@ describe("reserve api interaction with details", () => {
});
});
-describe("reserve api interaction with tip details", () => {
- it("should list tips", async () => {
+describe("reserve api interaction with reward details", () => {
+ it("should list rewards", async () => {
const env = new ApiMockEnvironment();
- env.addRequestExpectation(API_GET_TIP_BY_ID("11"), {
+ env.addRequestExpectation(API_GET_REWARD_BY_ID("11"), {
response: {
total_picked_up: "USD:12",
reason: "not",
- } as MerchantBackend.Tips.TipDetails,
+ } as MerchantBackend.Rewards.RewardDetails,
qparam: {
pickups: "yes",
},
@@ -418,7 +418,7 @@ describe("reserve api interaction with tip details", () => {
const hookBehavior = await tests.hookBehaveLikeThis(
() => {
- const query = useTipDetails("11");
+ const query = useRewardDetails("11");
return { query };
},
{},