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

Function testToArray

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

Source from the content-addressed store, hash-verified

3import testSharedMethods from '../Exchange/base/test.sharedMethods.js';
4
5function testToArray () {
6
7 const exchange = new ccxt.Exchange ({
8 'id': 'sampleexchange',
9 });
10
11 const obj1 = { 'a': 1, 'b': 3, 'c': 2 };
12 const obj2 = { 'a': 'x', 'b': 2 };
13 const result1 = exchange.toArray (obj1);
14 const result2 = exchange.toArray (obj2);
15
16 // we can't guarantee order of values in GO lang
17 // testSharedMethods.assertDeepEqual (exchange, undefined, 'testToArray', exchange.toArray (obj1), [ 1, 3, 2 ]);
18 // testSharedMethods.assertDeepEqual (exchange, undefined, 'testToArray', exchange.toArray (obj2), [ 'x', 2 ]);
19 //
20 assert (result1.length === 3, 'testToArray: length of result1 should be 3');
21 assert (result2.length === 2, 'testToArray: length of result2 should be 2');
22 assert (exchange.inArray (1, result1) && exchange.inArray (3, result1) && exchange.inArray (2, result1), 'testToArray: result1 should include 1, 3, and 2');
23 assert (exchange.inArray ('x', result2) && exchange.inArray (2, result2), 'testToArray: result2 should include "x" and 2');
24}
25
26export default testToArray;

Callers 1

baseTestsInitFunction · 0.70

Calls 3

toArrayMethod · 0.95
inArrayMethod · 0.95
assertFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…