diff options
author | Brandon Millman <brandon.millman@gmail.com> | 2018-01-09 10:02:41 +0800 |
---|---|---|
committer | Brandon Millman <brandon.millman@gmail.com> | 2018-01-09 10:02:41 +0800 |
commit | 8019b1b8231cac24dfc6aa3bb2d5115eff11ee89 (patch) | |
tree | d270d71404bd3aab44c79dcadf16e348614e9214 /packages/json-schemas/test/schema_test.ts | |
parent | 8fe81c9d090ce50496f3150602f19433e7aedd1e (diff) | |
parent | 7a56e83fa3ca02d796deba3359da480834a9f6ea (diff) | |
download | dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.gz dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.bz2 dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.lz dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.xz dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.tar.zst dexon-sol-tools-8019b1b8231cac24dfc6aa3bb2d5115eff11ee89.zip |
Merge branch 'development' into refactor/httpClientJsonParsing
* development: (21 commits)
Update connect CHANGELOG
Changes to abi-gen after code review
Added constructor ABIs to abi-gen
Describe #295 in a CHANGELOG
Add #302 description to changelog
Fix formatting
Apply prettier config
Install prettier
Remove formatting esilnt rules
sendTransactionAsync should return txHash string
Added Event generation to abi-gen
Publish
Add dates to CHANGELOG entries
Update subproviders CHANGELOG
Support both personal_sign and eth_sign
Fix Ledger tests given change from `personal_sign` to `eth_sign`
Update subprovider to catch correct RPC method
Rename guide
Update contribution guide
Fix broken links in the abi-gen README
...
Diffstat (limited to 'packages/json-schemas/test/schema_test.ts')
-rw-r--r-- | packages/json-schemas/test/schema_test.ts | 146 |
1 files changed, 34 insertions, 112 deletions
diff --git a/packages/json-schemas/test/schema_test.ts b/packages/json-schemas/test/schema_test.ts index e729c1925..b776f6e39 100644 --- a/packages/json-schemas/test/schema_test.ts +++ b/packages/json-schemas/test/schema_test.ts @@ -4,7 +4,7 @@ import * as dirtyChai from 'dirty-chai'; import forEach = require('lodash.foreach'); import 'mocha'; -import {schemas, SchemaValidator} from '../src/index'; +import { schemas, SchemaValidator } from '../src/index'; chai.config.includeStack = true; chai.use(dirtyChai); @@ -94,9 +94,9 @@ describe('Schema', () => { }); it('should fail for invalid parameters', () => { const testCases = [ - '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3', // shorter + '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc3', // shorter '0xzzzz9190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // invalid characters - '40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // no 0x + '40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', // no 0x ]; const shouldFail = true; validateAgainstSchema(testCases, ecSignatureParameterSchema, shouldFail); @@ -122,11 +122,7 @@ describe('Schema', () => { const v = 27; const r = '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33'; const s = '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254'; - const testCases = [ - {}, - {v}, - {r, s, v: 31}, - ]; + const testCases = [{}, { v }, { r, s, v: 31 }]; const shouldFail = true; validateAgainstSchema(testCases, ecSignatureSchema, shouldFail); }); @@ -152,37 +148,22 @@ describe('Schema', () => { }); describe('#blockParamSchema', () => { it('should validate valid block param', () => { - const testCases = [ - 42, - 'latest', - 'pending', - 'earliest', - ]; + const testCases = [42, 'latest', 'pending', 'earliest']; validateAgainstSchema(testCases, blockParamSchema); }); it('should fail for invalid block param', () => { - const testCases = [ - {}, - '42', - 'pemding', - ]; + const testCases = [{}, '42', 'pemding']; const shouldFail = true; validateAgainstSchema(testCases, blockParamSchema, shouldFail); }); }); describe('#blockRangeSchema', () => { it('should validate valid subscription opts', () => { - const testCases = [ - {fromBlock: 42, toBlock: 'latest'}, - {fromBlock: 42}, - {}, - ]; + const testCases = [{ fromBlock: 42, toBlock: 'latest' }, { fromBlock: 42 }, {}]; validateAgainstSchema(testCases, blockRangeSchema); }); it('should fail for invalid subscription opts', () => { - const testCases = [ - {fromBlock: '42'}, - ]; + const testCases = [{ fromBlock: '42' }]; const shouldFail = true; validateAgainstSchema(testCases, blockRangeSchema, shouldFail); }); @@ -196,9 +177,7 @@ describe('Schema', () => { url: 'https://0xproject.com', }; it('should validate valid token', () => { - const testCases = [ - token, - ]; + const testCases = [token]; validateAgainstSchema(testCases, tokenSchema); }); it('should fail for invalid token', () => { @@ -235,9 +214,7 @@ describe('Schema', () => { }; describe('#orderSchema', () => { it('should validate valid order', () => { - const testCases = [ - order, - ]; + const testCases = [order]; validateAgainstSchema(testCases, orderSchema); }); it('should fail for invalid order', () => { @@ -267,28 +244,18 @@ describe('Schema', () => { }; describe('#signedOrdersSchema', () => { it('should validate valid signed orders', () => { - const testCases = [ - [signedOrder], - [], - ]; + const testCases = [[signedOrder], []]; validateAgainstSchema(testCases, signedOrdersSchema); }); it('should fail for invalid signed orders', () => { - const testCases = [ - [ - signedOrder, - 1, - ], - ]; + const testCases = [[signedOrder, 1]]; const shouldFail = true; validateAgainstSchema(testCases, signedOrdersSchema, shouldFail); }); }); describe('#signedOrderSchema', () => { it('should validate valid signed order', () => { - const testCases = [ - signedOrder, - ]; + const testCases = [signedOrder]; validateAgainstSchema(testCases, signedOrderSchema); }); it('should fail for invalid signed order', () => { @@ -310,9 +277,7 @@ describe('Schema', () => { }, ]; it('should validate valid order fill or kill requests', () => { - const testCases = [ - orderFillOrKillRequests, - ]; + const testCases = [orderFillOrKillRequests]; validateAgainstSchema(testCases, orderFillOrKillRequestsSchema); }); it('should fail for invalid order fill or kill requests', () => { @@ -336,9 +301,7 @@ describe('Schema', () => { }, ]; it('should validate valid order cancellation requests', () => { - const testCases = [ - orderCancellationRequests, - ]; + const testCases = [orderCancellationRequests]; validateAgainstSchema(testCases, orderCancellationRequestsSchema); }); it('should fail for invalid order cancellation requests', () => { @@ -362,9 +325,7 @@ describe('Schema', () => { }, ]; it('should validate valid order fill requests', () => { - const testCases = [ - orderFillRequests, - ]; + const testCases = [orderFillRequests]; validateAgainstSchema(testCases, orderFillRequestsSchema); }); it('should fail for invalid order fill requests', () => { @@ -559,12 +520,8 @@ describe('Schema', () => { channel: 'orderbook', requestId: 2, payload: { - bids: [ - signedOrder, - ], - asks: [ - signedOrder, - ], + bids: [signedOrder], + asks: [signedOrder], }, }, ]; @@ -577,12 +534,8 @@ describe('Schema', () => { channel: 'orderbook', requestId: 2, payload: { - bids: [ - signedOrder, - ], - asks: [ - signedOrder, - ], + bids: [signedOrder], + asks: [signedOrder], }, }, { @@ -590,24 +543,16 @@ describe('Schema', () => { channel: 'bar', requestId: 2, payload: { - bids: [ - signedOrder, - ], - asks: [ - signedOrder, - ], + bids: [signedOrder], + asks: [signedOrder], }, }, { type: 'snapshot', channel: 'orderbook', payload: { - bids: [ - signedOrder, - ], - asks: [ - signedOrder, - ], + bids: [signedOrder], + asks: [signedOrder], }, }, { @@ -615,12 +560,8 @@ describe('Schema', () => { channel: 'orderbook', requestId: '2', payload: { - bids: [ - signedOrder, - ], - asks: [ - signedOrder, - ], + bids: [signedOrder], + asks: [signedOrder], }, }, { @@ -628,9 +569,7 @@ describe('Schema', () => { channel: 'orderbook', requestId: 2, payload: { - bids: [ - signedOrder, - ], + bids: [signedOrder], }, }, { @@ -638,9 +577,7 @@ describe('Schema', () => { channel: 'orderbook', requestId: 2, payload: { - asks: [ - signedOrder, - ], + asks: [signedOrder], }, }, { @@ -648,12 +585,8 @@ describe('Schema', () => { channel: 'orderbook', requestId: 2, payload: { - bids: [ - signedOrder, - ], - asks: [ - {}, - ], + bids: [signedOrder], + asks: [{}], }, }, { @@ -661,12 +594,8 @@ describe('Schema', () => { channel: 'orderbook', requestId: 2, payload: { - bids: [ - {}, - ], - asks: [ - signedOrder, - ], + bids: [{}], + asks: [signedOrder], }, }, ]; @@ -941,18 +870,11 @@ describe('Schema', () => { }); describe('#jsNumberSchema', () => { it('should validate valid js number', () => { - const testCases = [ - 1, - 42, - ]; + const testCases = [1, 42]; validateAgainstSchema(testCases, jsNumber); }); it('should fail for invalid js number', () => { - const testCases = [ - NaN, - -1, - new BigNumber(1), - ]; + const testCases = [NaN, -1, new BigNumber(1)]; const shouldFail = true; validateAgainstSchema(testCases, jsNumber, shouldFail); }); |