-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbittrex_pairs.test.js
155 lines (144 loc) · 5.49 KB
/
bittrex_pairs.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
const extract_bittrex_pairs = require("./extract_pairs");
describe('extract_bittrex_pairs', () => {
let bittrex;
let pairs;
let required_pairs;
beforeEach(() => {
bittrex = [
{
symbol: 'WAXP-BTC',
high: '0.000004400000',
low: '0.000004320000',
volume: '23937.59634439',
quoteVolume: '0.10429560',
percentChange: '0.92',
updatedAt: '2022-09-29T14:29:00.41Z'
},
{
symbol: 'WAXP-ETH',
high: '0.000063950000',
low: '0.000063140000',
volume: '1188.11330784',
quoteVolume: '0.07539428',
percentChange: '-0.96',
updatedAt: '2022-09-29T14:31:40.407Z'
},
{
symbol: 'WAXP-USD',
high: '0.089000000000',
low: '0.083031500000',
volume: '41745.65723008',
quoteVolume: '3552.27106637',
percentChange: '-0.66',
updatedAt: '2022-09-29T14:31:35.407Z'
},
{
symbol: 'WAXP-USDT',
high: '0.085434890000',
low: '0.083289740000',
volume: '67058.57870756',
quoteVolume: '5677.65411070',
percentChange: '-0.95',
updatedAt: '2022-09-29T14:31:00.437Z'
}
];
pairs = {
waxpbtc: {
active: 1,
bounty_awarded: 1,
bounty_edited_by_custodians: 0,
proposer: 'nate',
name: 'waxpbtc',
bounty_amount: '0.00000000 WAX',
approving_custodians: ['alohaeosprod'],
approving_oracles: [],
base_symbol: '8,WAXP',
base_type: 4,
base_contract: '',
quote_symbol: '8,BTC',
quote_type: 2,
quote_contract: '',
quoted_precision: 8
},
waxpeos: {
active: 1,
bounty_awarded: 1,
bounty_edited_by_custodians: 0,
proposer: 'eosdacserver',
name: 'waxpeos',
bounty_amount: '0.00000000 WAX',
approving_custodians: ['alohaeosprod', 'pink.gg'],
approving_oracles: ['alohaeosprod', 'eosdacserver', 'pink.gg'],
base_symbol: '8,WAXP',
base_type: 4,
base_contract: '',
quote_symbol: '4,EOS',
quote_type: 2,
quote_contract: '',
quoted_precision: 6
},
waxpeth: {
active: 1,
bounty_awarded: 1,
bounty_edited_by_custodians: 0,
proposer: 'eosdacserver',
name: 'waxpeth',
bounty_amount: '0.00000000 WAX',
approving_custodians: ['alohaeosprod', 'pink.gg'],
approving_oracles: ['alohaeosprod', 'eosdacserver', 'pink.gg'],
base_symbol: '8,WAXP',
base_type: 4,
base_contract: '',
quote_symbol: '18,ETH',
quote_type: 2,
quote_contract: '',
quoted_precision: 8
},
waxpusd: {
active: 1,
bounty_awarded: 1,
bounty_edited_by_custodians: 0,
proposer: 'nate',
name: 'waxpusd',
bounty_amount: '0.00000000 WAX',
approving_custodians: ['alohaeosprod'],
approving_oracles: [],
base_symbol: '8,WAXP',
base_type: 4,
base_contract: '',
quote_symbol: '2,USD',
quote_type: 1,
quote_contract: '',
quoted_precision: 4
}
};
required_pairs = ['waxpbtc', 'waxpeth', 'waxpusd'];
})
// Tests that the function extracts required pairs with correct format and precision and returns the expected output with valid input
it('should extract required pairs with correct format and precision and return expected output', () => {
expect(extract_bittrex_pairs(bittrex, pairs, required_pairs)).toStrictEqual([
{ "pair": "waxpbtc", "value": 436 },
{ "pair": "waxpeth", "value": 6355 },
{ "pair": "waxpusd", "value": 860 }
]);
});
// Tests that the function returns an empty array when the input arrays are empty
it('should return an empty array when the input arrays are empty', () => {
bittrex = [];
pairs = {};
required_pairs = [];
expect(extract_bittrex_pairs(bittrex, pairs, required_pairs)).toStrictEqual([]);
});
// Tests that the function throws an error when the input types are invalid
it('should throw an error when the input types are invalid', () => {
bittrex = null;
pairs = null;
required_pairs = null;
expect(() => extract_bittrex_pairs(bittrex, pairs, required_pairs)).toThrow();
});
// Tests that the function returns an empty array when there are missing required pairs
it('should return an empty array when there are missing required pairs', () => {
required_pairs = [];
expect(extract_bittrex_pairs(bittrex, pairs, required_pairs)).toStrictEqual([]);
});
});