aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-09 21:20:30 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-09 21:20:30 +0800
commitb46ebc76ea727056b3fa15ad814ee9dea511f225 (patch)
treeb4cf214c25245cb35c5d9f7b84fb9ce4eb9f419d /test
parent44f8d189624281b3f97926aa821faf99ad314ae5 (diff)
downloaddexon-sol-tools-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar
dexon-sol-tools-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.gz
dexon-sol-tools-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.bz2
dexon-sol-tools-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.lz
dexon-sol-tools-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.xz
dexon-sol-tools-b46ebc76ea727056b3fa15ad814ee9dea511f225.tar.zst
dexon-sol-tools-b46ebc76ea727056b3fa15ad814ee9dea511f225.zip
Add tests for TokenSchema
Diffstat (limited to 'test')
-rw-r--r--test/schema_test.ts39
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 = {