MCPcopy Create free account
hub / github.com/ccxt/ccxt / testUrlencode

Function testUrlencode

ts/src/test/base/test.urlencode.ts:5–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import testSharedMethods from '../Exchange/base/test.sharedMethods.js';
4
5function testUrlencode () {
6
7 const exchange = new ccxt.Exchange ({
8 'id': 'sampleexchange',
9 });
10
11 // todo: add nulls
12 // todo: add sort
13 const dict1 = {
14 'a': 1,
15 'c': '+&',
16 // 'd': undefined,
17 // 'e': null,
18 };
19 // as key-order not preserved, expect mixed order
20 const expected1 = 'a=1&c=%2B%26';
21 const expected2 = 'c=%2B%26&a=1';
22 const encoded = exchange.urlencode (dict1);
23 assert (encoded === expected1 || encoded === expected2, 'testUrlencode: expected ' + expected1 + ' or ' + expected2 + ' but got ' + encoded);
24
25 // todo: nested structure
26 //
27 // const dict2 = {
28 // 'a': 1,
29 // 'b': {
30 // 'c': 2,
31 // },
32 // 'd': [ 1, 2 ],
33 // };
34 // const expected2 = 'a=1&b[c]=2&d=1&d=2';
35
36 // assert (exchange.urlencode (dict2) === expected2, 'testUrlencode: expected ' + expected2 + ' but got ' + exchange.urlencode (dict2));
37}
38
39export default testUrlencode;

Callers 1

baseTestsInitFunction · 0.70

Calls 2

urlencodeMethod · 0.95
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…