()
| 17 | } |
| 18 | |
| 19 | function testSafeMethods () { |
| 20 | |
| 21 | const exchange = new ccxt.Exchange ({ |
| 22 | 'id': 'regirock', |
| 23 | }); |
| 24 | |
| 25 | const inputDict = { |
| 26 | 'i': 1, |
| 27 | 'f': 0.123, |
| 28 | 'bool': true, |
| 29 | 'list': [ 1, 2, 3 ], |
| 30 | 'dict': { 'a': 1 }, |
| 31 | 'listOfDicts': [ { 'a': 1 } ], |
| 32 | 'str': 'heLlo', |
| 33 | 'strNumber': '3', |
| 34 | // |
| 35 | 'zeroNumeric': 0, |
| 36 | 'zeroString': '0', |
| 37 | 'undefined': undefined, |
| 38 | 'emptyString': '', |
| 39 | 'floatNumeric': 0.123, |
| 40 | 'floatString': '0.123', |
| 41 | 'longInt': 123456789012345, |
| 42 | }; |
| 43 | |
| 44 | const inputList = [ 'Hi', 2 ]; |
| 45 | |
| 46 | const compareDict = { |
| 47 | 'a': 1, |
| 48 | }; |
| 49 | |
| 50 | const compareList = [ 1, 2, 3 ]; |
| 51 | |
| 52 | const factor = 10; |
| 53 | |
| 54 | // safeValue |
| 55 | assert (exchange.safeValue (inputDict, 'i') === 1); |
| 56 | assert (exchange.safeValue (inputDict, 'f') === 0.123); |
| 57 | assert (exchange.safeValue (inputDict, 'bool') === true); |
| 58 | assert (equals (exchange.safeValue (inputDict, 'list'), compareList)); |
| 59 | let dictObject = exchange.safeValue (inputDict, 'dict'); |
| 60 | assert (equals (dictObject, compareDict)); |
| 61 | assert (exchange.safeValue (inputDict, 'str') === 'heLlo'); |
| 62 | assert (exchange.safeValue (inputDict, 'strNumber') === '3'); |
| 63 | assert (exchange.safeValue (inputList, 0) === 'Hi'); |
| 64 | |
| 65 | // safeValue2 |
| 66 | assert (exchange.safeValue2 (inputDict, 'a', 'i') === 1); |
| 67 | assert (exchange.safeValue2 (inputDict, 'a', 'f') === 0.123); |
| 68 | assert (exchange.safeValue2 (inputDict, 'a', 'bool') === true); |
| 69 | assert (equals (exchange.safeValue2 (inputDict, 'a', 'list'), compareList)); |
| 70 | dictObject = exchange.safeValue2 (inputDict, 'a', 'dict'); |
| 71 | assert (equals (dictObject, compareDict)); |
| 72 | assert (exchange.safeValue2 (inputDict, 'a', 'str') === 'heLlo'); |
| 73 | assert (exchange.safeValue2 (inputDict, 'a', 'strNumber') === '3'); |
| 74 | assert (exchange.safeValue2 (inputList, 2, 0) === 'Hi'); |
| 75 | |
| 76 | // safeValueN |
no test coverage detected
searching dependent graphs…