diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-21 19:56:14 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-06-21 19:56:14 +0800 |
commit | 40a7be0690c81d2e42543aa075ef8da6606e7b7e (patch) | |
tree | 73231f3671133364b53d55074f27e03bd61a1d38 /test | |
parent | 096d3bdb26921cb3e7d05e65dc286ddf49f98a8a (diff) | |
download | dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.gz dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.bz2 dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.lz dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.xz dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.tar.zst dexon-sol-tools-40a7be0690c81d2e42543aa075ef8da6606e7b7e.zip |
Use different lodash import syntax which allows to include only used functions
Diffstat (limited to 'test')
-rw-r--r-- | test/0x.js_test.ts | 9 | ||||
-rw-r--r-- | test/schema_test.ts | 6 | ||||
-rw-r--r-- | test/token_registry_wrapper_test.ts | 4 | ||||
-rw-r--r-- | test/utils/order_factory.ts | 7 | ||||
-rw-r--r-- | test/utils/token_utils.ts | 10 |
5 files changed, 20 insertions, 16 deletions
diff --git a/test/0x.js_test.ts b/test/0x.js_test.ts index 9ec0a0c8e..b8e387f04 100644 --- a/test/0x.js_test.ts +++ b/test/0x.js_test.ts @@ -1,4 +1,5 @@ -import * as _ from 'lodash'; +import each from 'lodash/each'; +import assign from 'lodash/assign'; import * as chai from 'chai'; import {chaiSetup} from './utils/chai_setup'; import 'mocha'; @@ -67,7 +68,7 @@ describe('ZeroEx library', () => { ).to.become(false); }); it('should return false if the signature doesn\'t pertain to the dataHex & address', async () => { - const wrongSignature = _.assign({}, signature, {v: 28}); + const wrongSignature = assign({}, signature, {v: 28}); expect(ZeroEx.isValidSignature(dataHex, wrongSignature, address)).to.be.false(); return expect( (zeroEx.exchange as any)._isValidSignatureUsingContractCallAsync(dataHex, wrongSignature, address), @@ -144,7 +145,7 @@ describe('ZeroEx library', () => { let stubs: Sinon.SinonStub[] = []; afterEach(() => { // clean up any stubs after the test has completed - _.each(stubs, s => s.restore()); + each(stubs, s => s.restore()); stubs = []; }); it('calculates the order hash', async () => { @@ -171,7 +172,7 @@ describe('ZeroEx library', () => { }); afterEach(() => { // clean up any stubs after the test has completed - _.each(stubs, s => s.restore()); + each(stubs, s => s.restore()); stubs = []; }); it ('Should return the correct ECSignature on TestPRC nodeVersion', async () => { diff --git a/test/schema_test.ts b/test/schema_test.ts index b251a68f9..28abdc2c3 100644 --- a/test/schema_test.ts +++ b/test/schema_test.ts @@ -1,5 +1,5 @@ import 'mocha'; -import * as _ from 'lodash'; +import forEach from 'lodash/forEach'; import * as chai from 'chai'; import * as BigNumber from 'bignumber.js'; import promisify = require('es6-promisify'); @@ -19,7 +19,7 @@ const expect = chai.expect; describe('Schema', () => { const validator = new SchemaValidator(); const validateAgainstSchema = (testCases: any[], schema: any, shouldFail = false) => { - _.forEach(testCases, (testCase: any) => { + forEach(testCases, (testCase: any) => { if (shouldFail) { expect(validator.validate(testCase, schema).errors).to.be.lengthOf.at.least(1); } else { @@ -285,7 +285,7 @@ describe('Schema', () => { '00.00': '0', '.3': '0.3', }; - _.forEach(testCases, (serialized: string, input: string) => { + forEach(testCases, (serialized: string, input: string) => { expect(JSON.parse(JSON.stringify(new BigNumber(input)))).to.be.equal(serialized); }); }); diff --git a/test/token_registry_wrapper_test.ts b/test/token_registry_wrapper_test.ts index da436161c..74a02aa40 100644 --- a/test/token_registry_wrapper_test.ts +++ b/test/token_registry_wrapper_test.ts @@ -1,4 +1,4 @@ -import * as _ from 'lodash'; +import each from 'lodash/each'; import 'mocha'; import * as chai from 'chai'; import {chaiSetup} from './utils/chai_setup'; @@ -32,7 +32,7 @@ describe('TokenRegistryWrapper', () => { expect(tokens).to.have.lengthOf(TOKEN_REGISTRY_SIZE_AFTER_MIGRATION); const schemaValidator = new SchemaValidator(); - _.each(tokens, token => { + each(tokens, token => { const validationResult = schemaValidator.validate(token, tokenSchema); expect(validationResult.errors).to.have.lengthOf(0); }); diff --git a/test/utils/order_factory.ts b/test/utils/order_factory.ts index ef19f2c4c..ec16df22d 100644 --- a/test/utils/order_factory.ts +++ b/test/utils/order_factory.ts @@ -1,4 +1,5 @@ -import * as _ from 'lodash'; +import assign from 'lodash/assign'; +import isUndefined from 'lodash/isUndefined'; import * as BigNumber from 'bignumber.js'; import {ZeroEx, SignedOrder} from '../../src'; @@ -16,7 +17,7 @@ export const orderFactory = { feeRecipient: string, expirationUnixTimestampSec?: BigNumber.BigNumber): Promise<SignedOrder> { const defaultExpirationUnixTimestampSec = new BigNumber(2524604400); // Close to infinite - expirationUnixTimestampSec = _.isUndefined(expirationUnixTimestampSec) ? + expirationUnixTimestampSec = isUndefined(expirationUnixTimestampSec) ? defaultExpirationUnixTimestampSec : expirationUnixTimestampSec; const order = { @@ -34,7 +35,7 @@ export const orderFactory = { }; const orderHash = await zeroEx.getOrderHashHexAsync(order); const ecSignature = await zeroEx.signOrderHashAsync(orderHash, maker); - const signedOrder: SignedOrder = _.assign(order, {ecSignature}); + const signedOrder: SignedOrder = assign(order, {ecSignature}); return signedOrder; }, }; diff --git a/test/utils/token_utils.ts b/test/utils/token_utils.ts index f4fa7ac31..658cfe864 100644 --- a/test/utils/token_utils.ts +++ b/test/utils/token_utils.ts @@ -1,4 +1,6 @@ -import * as _ from 'lodash'; +import find from 'lodash/find'; +import filter from 'lodash/filter'; +import isUndefined from 'lodash/isUndefined'; import {Token, ZeroExError} from '../../src'; const PROTOCOL_TOKEN_SYMBOL = 'ZRX'; @@ -9,14 +11,14 @@ export class TokenUtils { this.tokens = tokens; } public getProtocolTokenOrThrow(): Token { - const zrxToken = _.find(this.tokens, {symbol: PROTOCOL_TOKEN_SYMBOL}); - if (_.isUndefined(zrxToken)) { + const zrxToken = find(this.tokens, {symbol: PROTOCOL_TOKEN_SYMBOL}); + if (isUndefined(zrxToken)) { throw new Error(ZeroExError.ZRX_NOT_IN_TOKEN_REGISTRY); } return zrxToken; } public getNonProtocolTokens(): Token[] { - const nonProtocolTokens = _.filter(this.tokens, token => { + const nonProtocolTokens = filter(this.tokens, token => { return token.symbol !== PROTOCOL_TOKEN_SYMBOL; }); return nonProtocolTokens; |