diff options
author | Florian Dold <florian.dold@gmail.com> | 2019-11-01 18:39:23 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2019-11-01 18:39:23 +0100 |
commit | ae8a00527168b13aa59ddc2fbd1f88a0f1e2669c (patch) | |
tree | a8599ee8efd254d468ec1ab29ce4ebdabd29c276 /src/taleruri-test.ts | |
parent | 1c5a9d2474f6281869c0ed0accbff4944359722a (diff) |
protocol changes
Diffstat (limited to 'src/taleruri-test.ts')
-rw-r--r-- | src/taleruri-test.ts | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/taleruri-test.ts b/src/taleruri-test.ts index bf4e9d493..360f565f7 100644 --- a/src/taleruri-test.ts +++ b/src/taleruri-test.ts @@ -15,7 +15,7 @@ */ import test from "ava"; -import { parsePayUri, parseWithdrawUri } from "./taleruri"; +import { parsePayUri, parseWithdrawUri, parseRefundUri, parseTipUri } from "./taleruri"; test("taler pay url parsing: http(s)", (t) => { const url1 = "https://example.com/bar?spam=eggs"; @@ -150,3 +150,57 @@ test("taler withdraw uri parsing", (t) => { } t.is(r1.statusUrl, "https://bank.example.com/api/withdraw-operation/12345"); }); + + +test("taler refund uri parsing", (t) => { + const url1 = "taler://refund/merchant.example.com/-/-/1234"; + const r1 = parseRefundUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.refundUrl, "https://merchant.example.com/public/refund?order_id=1234"); +}); + + +test("taler refund uri parsing with instance", (t) => { + const url1 = "taler://refund/merchant.example.com/-/myinst/1234"; + const r1 = parseRefundUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.refundUrl, "https://merchant.example.com/public/instances/myinst/refund?order_id=1234"); +}); + +test("taler tip pickup uri", (t) => { + const url1 = "taler://tip/merchant.example.com/-/-/tipid"; + const r1 = parseTipUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.tipPickupUrl, "https://merchant.example.com/public/tip-pickup?tip_id=tipid"); +}); + + +test("taler tip pickup uri with instance", (t) => { + const url1 = "taler://tip/merchant.example.com/-/tipm/tipid"; + const r1 = parseTipUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.tipPickupUrl, "https://merchant.example.com/public/instances/tipm/tip-pickup?tip_id=tipid"); +}); + + +test("taler tip pickup uri with instance and prefix", (t) => { + const url1 = "taler://tip/merchant.example.com/my%2fpfx/tipm/tipid"; + const r1 = parseTipUri(url1); + if (!r1) { + t.fail(); + return; + } + t.is(r1.tipPickupUrl, "https://merchant.example.com/my/pfx/instances/tipm/tip-pickup?tip_id=tipid"); +}); |