From 64cf47f297827a869120b85e734406db87b87db8 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 3 Jul 2017 21:59:42 -0700 Subject: Add tests for subscriptionOptsSchema and blockParamSchema --- test/schema_test.ts | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'test') diff --git a/test/schema_test.ts b/test/schema_test.ts index b251a68f9..7f9a66ae3 100644 --- a/test/schema_test.ts +++ b/test/schema_test.ts @@ -12,6 +12,7 @@ import {orderFillOrKillRequestsSchema} from '../src/schemas/order_fill_or_kill_r import {ecSignatureParameterSchema, ecSignatureSchema} from '../src/schemas/ec_signature_schema'; import {orderCancellationRequestsSchema} from '../src/schemas/order_cancel_schema'; import {orderFillRequestsSchema} from '../src/schemas/order_fill_requests_schema'; +import {blockParamSchema, subscriptionOptsSchema} from '../src/schemas/subscription_opts_schema'; chai.config.includeStack = true; const expect = chai.expect; @@ -96,6 +97,43 @@ describe('Schema', () => { validateAgainstSchema(testCases, ecSignatureSchema, shouldFail); }); }); + describe('#blockParamSchema', () => { + it('should validate valid block param', () => { + const testCases = [ + 42, + 'latest', + 'pending', + 'earliest', + ]; + validateAgainstSchema(testCases, blockParamSchema); + }); + it('should fail for invalid block param', () => { + const testCases = [ + {}, + '42', + 'pemding', + ]; + const shouldFail = true; + validateAgainstSchema(testCases, blockParamSchema, shouldFail); + }); + }); + describe('#subscriptionOptsSchema', () => { + it('should validate valid subscription opts', () => { + const testCases = [ + {fromBlock: 42, toBlock: 'latest'}, + ]; + validateAgainstSchema(testCases, subscriptionOptsSchema); + }); + it('should fail for invalid subscription opts', () => { + const testCases = [ + {}, + {fromBlock: 42}, + {fromBlock: 42, to: 43}, + ]; + const shouldFail = true; + validateAgainstSchema(testCases, subscriptionOptsSchema, shouldFail); + }); + }); describe('#tokenSchema', () => { const token = { name: 'Zero Ex', -- cgit v1.2.3