-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for orderBookSnapshot event
- Loading branch information
1 parent
d9f2bf4
commit 50cdbc0
Showing
3 changed files
with
160 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
tests/clients/testCases/validWsOrderBookSnapshotTestCases.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import BigNumber from 'bignumber.js'; | ||
|
||
import type { WebSocketOrderBookSnapshotResponseDto } from '../../../src/clients/dtos'; | ||
import type { OrderBook, } from '../../../src/exchange/index'; | ||
|
||
const validWsOrderBookSnapshotTestCases: ReadonlyArray<readonly [ | ||
message: string, | ||
testValue: readonly [snapshotDtos: WebSocketOrderBookSnapshotResponseDto[], expectedOrderBooks: OrderBook[]] | ||
]> = [ | ||
[ | ||
'Single snapshot', | ||
[ | ||
[{ | ||
event: 'snapshot', | ||
data: { | ||
updateId: 57551, | ||
symbol: 'ETH/BTC', | ||
entries: [{ | ||
side: 'Buy', | ||
price: 0.06688964, | ||
qtyProfile: [4.0] | ||
}, { | ||
side: 'Sell', | ||
price: 0.06754710, | ||
qtyProfile: [1.5] | ||
}] | ||
} | ||
}], | ||
[{ | ||
updateId: 57551, | ||
symbol: 'ETH/BTC', | ||
quoteCurrency: 'ETH', | ||
baseCurrency: 'BTC', | ||
entries: [ | ||
{ | ||
side: 'Buy', | ||
price: new BigNumber(0.06688964), | ||
qtyProfile: [4.0] | ||
}, | ||
{ | ||
side: 'Sell', | ||
price: new BigNumber(0.06754710), | ||
qtyProfile: [1.5] | ||
} | ||
] | ||
}] | ||
] | ||
], | ||
[ | ||
'Several snapshots', | ||
[ | ||
[{ | ||
event: 'snapshot', | ||
data: { | ||
updateId: 57551, | ||
symbol: 'ETH/BTC', | ||
entries: [{ | ||
side: 'Buy', | ||
price: 0.06688964, | ||
qtyProfile: [4.0] | ||
}, { | ||
side: 'Sell', | ||
price: 0.06754710, | ||
qtyProfile: [1.5] | ||
}] | ||
} | ||
}, { | ||
event: 'snapshot', | ||
data: { | ||
updateId: 57552, | ||
symbol: 'XTZ/ETH', | ||
entries: [{ | ||
side: 'Buy', | ||
price: 0.66666666, | ||
qtyProfile: [5.5] | ||
}, { | ||
side: 'Sell', | ||
price: 0.77777777, | ||
qtyProfile: [3.0] | ||
}] | ||
} | ||
}], | ||
[{ | ||
updateId: 57551, | ||
symbol: 'ETH/BTC', | ||
quoteCurrency: 'ETH', | ||
baseCurrency: 'BTC', | ||
entries: [ | ||
{ | ||
side: 'Buy', | ||
price: new BigNumber(0.06688964), | ||
qtyProfile: [4.0] | ||
}, | ||
{ | ||
side: 'Sell', | ||
price: new BigNumber(0.06754710), | ||
qtyProfile: [1.5] | ||
} | ||
] | ||
}, { | ||
updateId: 57552, | ||
symbol: 'XTZ/ETH', | ||
quoteCurrency: 'XTZ', | ||
baseCurrency: 'ETH', | ||
entries: [ | ||
{ | ||
side: 'Buy', | ||
price: new BigNumber(0.66666666), | ||
qtyProfile: [5.5] | ||
}, | ||
{ | ||
side: 'Sell', | ||
price: new BigNumber(0.77777777), | ||
qtyProfile: [3.0] | ||
} | ||
] | ||
}] | ||
] | ||
], | ||
]; | ||
|
||
export default validWsOrderBookSnapshotTestCases; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters