()
| 4 | import ccxt from '../../../ccxt.js'; |
| 5 | |
| 6 | function testRawencode () { |
| 7 | |
| 8 | const exchange = new ccxt.Exchange ({ |
| 9 | 'id': 'sampleexchange', |
| 10 | }); |
| 11 | |
| 12 | |
| 13 | // todo: add sort |
| 14 | // todo: add nulls |
| 15 | const dict2 = { |
| 16 | 'a': 1, |
| 17 | 'b': '+&', |
| 18 | }; |
| 19 | // as key-order not preserved, expect mixed orde |
| 20 | const expected2a = 'a=1&b=+&'; |
| 21 | const expected2b = 'b=+&&a=1'; |
| 22 | const result2 = exchange.rawencode (dict2); |
| 23 | |
| 24 | assert (result2 === expected2a || result2 === expected2b, 'rawencode: expected ' + expected2a + ' or ' + expected2b + ' but got ' + result2); |
| 25 | |
| 26 | // todo: fails in python, like: 'AssertionError'> rawencode: expected a=1&b[c]=2&b[something]=+&&d[0]=1&d[1]=2 but got a=1&b={'c': 2, 'something': '+&'}&d=[1, 2] |
| 27 | // |
| 28 | // const dict2 = { |
| 29 | // 'a': 1, |
| 30 | // 'b': { |
| 31 | // 'c': 2, |
| 32 | // 'something': '+&' |
| 33 | // }, |
| 34 | // 'd': [ 1, 2 ], |
| 35 | // }; |
| 36 | // const expected2 = 'a=1&b[c]=2&b[something]=+&&d[0]=1&d[1]=2'; |
| 37 | |
| 38 | // assert (exchange.rawencode (dict2) === expected2, 'rawencode: expected ' + expected2 + ' but got ' + exchange.rawencode (dict2)); |
| 39 | } |
| 40 | |
| 41 | export default testRawencode; |
no test coverage detected
searching dependent graphs…