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