diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-09 21:20:30 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-09 21:20:30 +0800 |
commit | b46ebc76ea727056b3fa15ad814ee9dea511f225 (patch) | |
tree | b4cf214c25245cb35c5d9f7b84fb9ce4eb9f419d /test/schema_test.ts | |
parent | 44f8d189624281b3f97926aa821faf99ad314ae5 (diff) | |
download | dexon-0x-contracts-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar dexon-0x-contracts-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.gz dexon-0x-contracts-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.bz2 dexon-0x-contracts-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.lz dexon-0x-contracts-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.xz dexon-0x-contracts-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.zst dexon-0x-contracts-b46ebc76ea727056b3fa15ad814ee9dea511f225.zip |
Add tests for TokenSchema
Diffstat (limited to 'test/schema_test.ts')
-rw-r--r-- | test/schema_test.ts | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/test/schema_test.ts b/test/schema_test.ts index 1a4275ebb..5df0094c3 100644 --- a/test/schema_test.ts +++ b/test/schema_test.ts @@ -5,6 +5,7 @@ import * as BigNumber from 'bignumber.js'; 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 {addressSchema, numberSchema} from '../src/schemas/basic_type_schemas'; import {ecSignatureParameterSchema, ecSignatureSchema} from '../src/schemas/ec_signature_schema'; @@ -38,7 +39,7 @@ describe('Schema', () => { batchTestSchema(testCases, addressSchema, true); }); }); - describe('#ecSignatureParameter', () => { + describe('#ecSignatureParameterSchema', () => { it('should validate valid parameters', () => { const testCases = [ '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', @@ -55,7 +56,7 @@ describe('Schema', () => { batchTestSchema(testCases, ecSignatureParameterSchema, true); }); }); - describe('#ecSignature', () => { + describe('#ecSignatureSchema', () => { it('should validate valid signature', () => { const signature = { v: 27, @@ -83,6 +84,40 @@ describe('Schema', () => { batchTestSchema(testCases, ecSignatureSchema, true); }); }); + describe('#tokenSchema', () => { + const token = { + name: 'Zero Ex', + symbol: 'ZRX', + decimals: 100500, + address: '0x8b0292B11a196601eD2ce54B665CaFEca0347D42', + url: 'https://0xproject.com', + }; + it('should validate valid token', () => { + const testCases = [ + token, + ]; + batchTestSchema(testCases, tokenSchema); + }); + it('should fail for invalid token', () => { + const testCases = [ + { + ...token, + address: null, + }, + { + ...token, + decimals: undefined, + }, + [], + 4, + { + ...token, + url: 'not an url', + }, + ]; + batchTestSchema(testCases, tokenSchema, true); + }); + }); describe('BigNumber serialization', () => { it('should correctly serialize BigNumbers', () => { const testCases = { |