aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-07-04 12:59:42 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-07-04 12:59:42 +0800
commit64cf47f297827a869120b85e734406db87b87db8 (patch)
tree2130a72b7a5cb45b75072124e1a6684fdca9a0f2
parent7d7bef2b1a83a570be58c8c0c90c9e338c3b93f3 (diff)
downloaddexon-0x-contracts-64cf47f297827a869120b85e734406db87b87db8.tar.gz
dexon-0x-contracts-64cf47f297827a869120b85e734406db87b87db8.tar.zst
dexon-0x-contracts-64cf47f297827a869120b85e734406db87b87db8.zip
Add tests for subscriptionOptsSchema and blockParamSchema
-rw-r--r--test/schema_test.ts38
1 files changed, 38 insertions, 0 deletions
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',