aboutsummaryrefslogtreecommitdiffstats
path: root/test/schema_test.ts
diff options
context:
space:
mode:
authorLeonid <logvinov.leon@gmail.com>2017-07-05 09:17:57 +0800
committerGitHub <noreply@github.com>2017-07-05 09:17:57 +0800
commit74b2308488832290340f3a6c6473ab7340510dfc (patch)
treebe598e0355a72486125cacfad837a2d06342f170 /test/schema_test.ts
parent3302d18f6e0a4b7e51b318959c6b2d040ae3c5ed (diff)
parent371acc0ba12197de735dea20e09d50bbfd524118 (diff)
downloaddexon-sol-tools-74b2308488832290340f3a6c6473ab7340510dfc.tar
dexon-sol-tools-74b2308488832290340f3a6c6473ab7340510dfc.tar.gz
dexon-sol-tools-74b2308488832290340f3a6c6473ab7340510dfc.tar.bz2
dexon-sol-tools-74b2308488832290340f3a6c6473ab7340510dfc.tar.lz
dexon-sol-tools-74b2308488832290340f3a6c6473ab7340510dfc.tar.xz
dexon-sol-tools-74b2308488832290340f3a6c6473ab7340510dfc.tar.zst
dexon-sol-tools-74b2308488832290340f3a6c6473ab7340510dfc.zip
Merge pull request #90 from 0xProject/subscribe-token
Add implementation and tests for zeroEx.token.subscribeAsync
Diffstat (limited to 'test/schema_test.ts')
-rw-r--r--test/schema_test.ts59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/schema_test.ts b/test/schema_test.ts
index b251a68f9..c170bebb1 100644
--- a/test/schema_test.ts
+++ b/test/schema_test.ts
@@ -6,12 +6,14 @@ import promisify = require('es6-promisify');
import {constants} from './utils/constants';
import {SchemaValidator} from '../src/utils/schema_validator';
import {tokenSchema} from '../src/schemas/token_schema';
+import {orderHashSchema} from '../src/schemas/order_hash_schema';
import {orderSchema, signedOrderSchema} from '../src/schemas/order_schemas';
import {addressSchema, numberSchema} from '../src/schemas/basic_type_schemas';
import {orderFillOrKillRequestsSchema} from '../src/schemas/order_fill_or_kill_requests_schema';
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 +98,62 @@ describe('Schema', () => {
validateAgainstSchema(testCases, ecSignatureSchema, shouldFail);
});
});
+ describe('#orderHashSchema', () => {
+ it('should validate valid order hash', () => {
+ const testCases = [
+ '0x61a3ed31B43c8780e905a260a35faefEc527be7516aa11c0256729b5b351bc33',
+ '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254',
+ ];
+ validateAgainstSchema(testCases, orderHashSchema);
+ });
+ it('should fail for invalid order hash', () => {
+ const testCases = [
+ {},
+ '0x',
+ '0x8b0292B11a196601eD2ce54B665CaFEca0347D42',
+ '61a3ed31B43c8780e905a260a35faefEc527be7516aa11c0256729b5b351bc33',
+ ];
+ const shouldFail = true;
+ validateAgainstSchema(testCases, orderHashSchema, 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'},
+ {fromBlock: 42},
+ {},
+ ];
+ validateAgainstSchema(testCases, subscriptionOptsSchema);
+ });
+ it('should fail for invalid subscription opts', () => {
+ const testCases = [
+ {fromBlock: '42'},
+ ];
+ const shouldFail = true;
+ validateAgainstSchema(testCases, subscriptionOptsSchema, shouldFail);
+ });
+ });
describe('#tokenSchema', () => {
const token = {
name: 'Zero Ex',
@@ -143,6 +201,7 @@ describe('Schema', () => {
takerTokenAddress: constants.NULL_ADDRESS,
salt: '256',
feeRecipient: constants.NULL_ADDRESS,
+ exchangeContractAddress: constants.NULL_ADDRESS,
expirationUnixTimestampSec: '42',
};
describe('#orderSchema', () => {