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

Function testUrlencode

js/src/test/base/test.urlencode.js:3–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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