diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-09 22:12:48 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-09 22:12:48 +0800 |
commit | 96ef9dbaafb12bd733fdcf0b9767c1d9b0f2da5b (patch) | |
tree | d25633ca304bb2da43c38e907ed6e5327f85b262 | |
parent | 941df26dff802fc8a73ec289ce84d1e54451668e (diff) | |
download | dexon-0x-contracts-96ef9dbaafb12bd733fdcf0b9767c1d9b0f2da5b.tar.gz dexon-0x-contracts-96ef9dbaafb12bd733fdcf0b9767c1d9b0f2da5b.tar.zst dexon-0x-contracts-96ef9dbaafb12bd733fdcf0b9767c1d9b0f2da5b.zip |
Refactor tests
-rw-r--r-- | test/schema_test.ts | 100 |
1 files changed, 47 insertions, 53 deletions
diff --git a/test/schema_test.ts b/test/schema_test.ts index fb5aba321..29375e9e9 100644 --- a/test/schema_test.ts +++ b/test/schema_test.ts @@ -123,7 +123,7 @@ describe('Schema', () => { validateAgainstSchema(testCases, tokenSchema, true); }); }); - describe('#orderSchema', () => { + describe('order including schemas', () => { const order = { maker: constants.NULL_ADDRESS, taker: constants.NULL_ADDRESS, @@ -137,60 +137,54 @@ describe('Schema', () => { feeRecipient: constants.NULL_ADDRESS, expirationUnixTimestampSec: 42, }; - it('should validate valid order', () => { - const testCases = [ - order, - ]; - validateAgainstSchema(testCases, orderSchema); - }); - it('should fail for invalid order', () => { - const testCases = [ - { - ...order, - salt: undefined, - }, - { - ...order, - salt: 'salt', - }, - 'order', - ]; - validateAgainstSchema(testCases, orderSchema, true); - }); - }); - describe('#signedOrderSchema', () => { - const signedOrder = { - maker: constants.NULL_ADDRESS, - taker: constants.NULL_ADDRESS, - makerFee: 1, - takerFee: 2, - makerTokenAmount: 1, - takerTokenAmount: 2, - makerTokenAddress: constants.NULL_ADDRESS, - takerTokenAddress: constants.NULL_ADDRESS, - salt: 256, - feeRecipient: constants.NULL_ADDRESS, - expirationUnixTimestampSec: 42, - ecSignature: { - v: 27, - r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', - s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', - }, - }; - it('should validate valid order', () => { - const testCases = [ - signedOrder, - ]; - validateAgainstSchema(testCases, orderSchema); + describe('#orderSchema', () => { + it('should validate valid order', () => { + const testCases = [ + order, + ]; + validateAgainstSchema(testCases, orderSchema); + }); + it('should fail for invalid order', () => { + const testCases = [ + { + ...order, + salt: undefined, + }, + { + ...order, + salt: 'salt', + }, + 'order', + ]; + validateAgainstSchema(testCases, orderSchema, true); + }); }); - it('should fail for invalid order', () => { - const testCases = [ - { - ...signedOrder, - ecSignature: undefined, + describe('signed order including schemas', () => { + const signedOrder = { + ...order, + ecSignature: { + v: 27, + r: '0x61a3ed31b43c8780e905a260a35faefcc527be7516aa11c0256729b5b351bc33', + s: '0x40349190569279751135161d22529dc25add4f6069af05be04cacbda2ace2254', }, - ]; - validateAgainstSchema(testCases, orderSchema, true); + }; + describe('#signedOrderSchema', () => { + it('should validate valid order', () => { + const testCases = [ + signedOrder, + ]; + validateAgainstSchema(testCases, orderSchema); + }); + it('should fail for invalid order', () => { + const testCases = [ + { + ...signedOrder, + ecSignature: undefined, + }, + ]; + validateAgainstSchema(testCases, orderSchema, true); + }); + }); }); }); describe('BigNumber serialization', () => { |