Add requestId to subscription messages and update json-schemas

This commit is contained in:
Brandon Millman
2017-12-04 23:58:33 -08:00
parent c0015c2c11
commit 20e28d6c70
13 changed files with 101 additions and 50 deletions

View File

@@ -41,12 +41,22 @@ describe('orderbookChannelMessageParsers', () => {
it('throws when message does not include a type', () => {
const typelessMessage = `{
"channel": "orderbook",
"channelId": 1,
"requestId": 1,
"payload": {}
}`;
const badCall = () => orderbookChannelMessageParsers.parser(typelessMessage);
expect(badCall).throws(`Message is missing a type parameter: ${typelessMessage}`);
});
it('throws when type is not a string', () => {
const messageWithBadType = `{
"type": 1,
"channel": "orderbook",
"requestId": 1,
"payload": {}
}`;
const badCall = () => orderbookChannelMessageParsers.parser(messageWithBadType);
expect(badCall).throws('Expected type to be of type string, encountered: 1');
});
it('throws when snapshot message has malformed payload', () => {
const badCall = () =>
orderbookChannelMessageParsers.parser(malformedSnapshotOrderbookChannelMessage);