aboutsummaryrefslogtreecommitdiff
path: root/packages/taler-util/src/taleruri.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/taler-util/src/taleruri.test.ts')
-rw-r--r--packages/taler-util/src/taleruri.test.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts
index 3ee243fb3..a6c4d89fc 100644
--- a/packages/taler-util/src/taleruri.test.ts
+++ b/packages/taler-util/src/taleruri.test.ts
@@ -22,6 +22,8 @@ import {
parseTipUri,
parsePayPushUri,
constructPayPushUri,
+ parsePayTemplateUri,
+ constructPayUri,
} from "./taleruri.js";
test("taler pay url parsing: wrong scheme", (t) => {
@@ -225,3 +227,37 @@ test("taler peer to peer push URI (construction)", (t) => {
});
t.deepEqual(url, "taler://pay-push/foo.example.com/bla/123");
});
+
+test("taler pay URI (construction)", (t) => {
+ const url1 = constructPayUri("http://localhost:123/", "foo", "");
+ t.deepEqual(url1, "taler+http://pay/localhost:123/foo/");
+
+ const url2 = constructPayUri("http://localhost:123/", "foo", "bla");
+ t.deepEqual(url2, "taler+http://pay/localhost:123/foo/bla");
+});
+
+test("taler pay template URI (parsing)", (t) => {
+ const url1 =
+ "taler://pay-template/merchant.example.com/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY?amount=KUDOS:5";
+ const r1 = parsePayTemplateUri(url1);
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.deepEqual(r1.merchantBaseUrl, "https://merchant.example.com/");
+ t.deepEqual(r1.templateId, "FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY");
+ t.deepEqual(r1.templateParams.amount, "KUDOS:5");
+});
+
+test("taler pay template URI (parsing, http with port)", (t) => {
+ const url1 =
+ "taler+http://pay-template/merchant.example.com:1234/FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY?amount=KUDOS:5";
+ const r1 = parsePayTemplateUri(url1);
+ if (!r1) {
+ t.fail();
+ return;
+ }
+ t.deepEqual(r1.merchantBaseUrl, "http://merchant.example.com:1234/");
+ t.deepEqual(r1.templateId, "FEGHYJY48FEGU6WETYIOIDEDE2QW3OCZVY");
+ t.deepEqual(r1.templateParams.amount, "KUDOS:5");
+});