-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathliquidations.js
More file actions
51 lines (45 loc) · 1.72 KB
/
liquidations.js
File metadata and controls
51 lines (45 loc) · 1.72 KB
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
/* eslint-env mocha */
'use strict'
const assert = require('assert')
const _includes = require('lodash/includes')
const { SYMBOLS } = require('bfx-hf-util')
const { Liquidations } = require('../../../lib')
const testModel = require('../../helpers/test_model')
const testModelValidation = require('../../helpers/test_model_validation')
const VALID_SYMBOLS = Object.values(SYMBOLS)
describe('Liquidations entry model', () => {
testModel({
model: Liquidations,
orderedFields: [
null, 'posId', 'mtsUpdated', null, 'symbol', 'amount', 'basePrice', null, 'isMatch', 'isMarketSold', null, 'liquidationPrice'
]
})
testModelValidation({
model: Liquidations,
validData: {
symbol: VALID_SYMBOLS,
posId: new Array(...(new Array(5))).map(() => Math.random()),
mtsUpdated: new Array(...(new Array(5))).map(() => Math.random()),
amount: new Array(...(new Array(5))).map(() => Math.random()),
basePrice: new Array(...(new Array(5))).map(() => Math.random()),
isMatch: new Array(...(new Array(5))).map(() => Math.random() > 0.5),
isMarketSold: new Array(...(new Array(5))).map(() => Math.random() > 0.5),
liquidationPrice: new Array(...(new Array(5))).map(() => Math.random())
}
})
describe('toString', () => {
it('includes pertinent information', () => {
const l = new Liquidations({
symbol: 'tBTCUSD',
amount: 42,
basePrice: 0.1,
liquidationPrice: 33
})
const str = l.toString()
assert.ok(/BTCUSD/.test(str), 'symbol missing')
assert.ok(_includes(str, '42'), 'amount missing')
assert.ok(_includes(str, '0.1'), 'rate missing')
assert.ok(_includes(str, '33'), 'liquidationPrice missing')
})
})
})