diff options
author | Sebastian <sebasjm@gmail.com> | 2023-06-26 12:54:54 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-06-26 12:54:54 -0300 |
commit | 74579ac2f2a4dd46487fb4d2bb2f2b26961a54f1 (patch) | |
tree | 95317d59ece7d61fafd29f00dda148d545c72849 /packages/taler-util/src/taleruri.test.ts | |
parent | 4b61945f6b7b073acf5de825b7678bddc56ad5d0 (diff) | |
download | wallet-core-74579ac2f2a4dd46487fb4d2bb2f2b26961a54f1.tar.xz |
withdraw exchange URI
Diffstat (limited to 'packages/taler-util/src/taleruri.test.ts')
-rw-r--r-- | packages/taler-util/src/taleruri.test.ts | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/packages/taler-util/src/taleruri.test.ts b/packages/taler-util/src/taleruri.test.ts index ffc56a723..3244bbbd9 100644 --- a/packages/taler-util/src/taleruri.test.ts +++ b/packages/taler-util/src/taleruri.test.ts @@ -22,10 +22,12 @@ import { parseRefundUri, parseRestoreUri, parseTipUri, + parseWithdrawExchangeUri, parseWithdrawUri, stringifyPayPushUri, stringifyPayUri, stringifyRestoreUri, + stringifyWithdrawExchange, } from "./taleruri.js"; test("taler pay url parsing: wrong scheme", (t) => { @@ -329,3 +331,42 @@ test("taler restore URI (stringify)", (t) => { "taler://restore/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0/http%3A%2F%2Fprov1.example.com%2F,https%3A%2F%2Fprov2.example.com%3A234%2F", ); }); + +test("taler withdraw exchange URI (parse)", (t) => { + const r1 = parseWithdrawExchangeUri( + "taler://withdraw-exchange/exchange.demo.taler.net/someroot/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0?a=KUDOS%3A2", + ); + if (!r1) { + t.fail(); + return; + } + t.deepEqual( + r1.exchangePub, + "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0", + ); + t.deepEqual(r1.exchangeBaseUrl, "https://exchange.demo.taler.net/someroot/"); + t.deepEqual(r1.amount, "KUDOS:2"); +}); + +test("taler withdraw exchange URI (stringify)", (t) => { + const url = stringifyWithdrawExchange({ + exchangeBaseUrl: "https://exchange.demo.taler.net", + exchangePub: "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0", + }); + t.deepEqual( + url, + "taler://withdraw-exchange/exchange.demo.taler.net/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0", + ); +}); + +test("taler withdraw exchange URI with amount (stringify)", (t) => { + const url = stringifyWithdrawExchange({ + exchangeBaseUrl: "https://exchange.demo.taler.net", + exchangePub: "GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0", + amount: "KUDOS:19", + }); + t.deepEqual( + url, + "taler://withdraw-exchange/exchange.demo.taler.net/GJKG23V4ZBHEH45YRK7TWQE8ZTY7JWTY5094TQJSRZN5DSDBX8E0?a=KUDOS%3A19", + ); +}); |