@0x:contracts-integrations
Switched to object destructuring in the function assertion unit test
This commit is contained in:
parent
e603a81a46
commit
718407ba6f
@ -67,7 +67,7 @@ jobs:
|
|||||||
- restore_cache:
|
- restore_cache:
|
||||||
keys:
|
keys:
|
||||||
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
- repo-{{ .Environment.CIRCLE_SHA1 }}
|
||||||
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-exchange-forwarder @0x/contracts-dev-utils @0x/contracts-staking @0x/contracts-coordinator @0x/contracts-integrations
|
- run: yarn wsrun test:circleci @0x/contracts-multisig @0x/contracts-utils @0x/contracts-exchange-libs @0x/contracts-erc20 @0x/contracts-erc721 @0x/contracts-erc1155 @0x/contracts-asset-proxy @0x/contracts-exchange-forwarder @0x/contracts-tests @0x/contracts-staking @0x/contracts-coordinator @0x/contracts-integrations
|
||||||
# TODO(dorothy-zbornak): Re-enable after updating this package for 3.0.
|
# TODO(dorothy-zbornak): Re-enable after updating this package for 3.0.
|
||||||
# - run: yarn wsrun test:circleci @0x/contracts-extensions
|
# - run: yarn wsrun test:circleci @0x/contracts-extensions
|
||||||
test-publish:
|
test-publish:
|
||||||
|
@ -12,8 +12,7 @@ import { TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
|||||||
import { artifacts, TestFrameworkContract, TestFrameworkEventEventArgs, TestFrameworkEvents } from '../../src';
|
import { artifacts, TestFrameworkContract, TestFrameworkEventEventArgs, TestFrameworkEvents } from '../../src';
|
||||||
import { FunctionAssertion, Result } from '../utils/function_assertions';
|
import { FunctionAssertion, Result } from '../utils/function_assertions';
|
||||||
|
|
||||||
const ZERO = constants.ZERO_AMOUNT;
|
const { ZERO_AMOUNT, MAX_UINT256 } = constants;
|
||||||
const MAX_UINT256 = constants.MAX_UINT256;
|
|
||||||
|
|
||||||
blockchainTests.resets('FunctionAssertion Unit Tests', env => {
|
blockchainTests.resets('FunctionAssertion Unit Tests', env => {
|
||||||
let exampleContract: TestFrameworkContract;
|
let exampleContract: TestFrameworkContract;
|
||||||
@ -29,27 +28,27 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
|
|||||||
|
|
||||||
describe('runAsync', () => {
|
describe('runAsync', () => {
|
||||||
it('should call the before function with the provided arguments', async () => {
|
it('should call the before function with the provided arguments', async () => {
|
||||||
let sideEffectTarget = ZERO;
|
let sideEffectTarget = ZERO_AMOUNT;
|
||||||
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
|
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
|
||||||
before: async (input: BigNumber) => {
|
before: async (input: BigNumber) => {
|
||||||
sideEffectTarget = randomInput;
|
sideEffectTarget = randomInput;
|
||||||
},
|
},
|
||||||
after: async (beforeInfo: any, result: Result, input: BigNumber) => {},
|
after: async (beforeInfo: any, result: Result, input: BigNumber) => {},
|
||||||
});
|
});
|
||||||
const randomInput = getRandomInteger(ZERO, MAX_UINT256);
|
const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256);
|
||||||
await assertion.runAsync(randomInput);
|
await assertion.runAsync(randomInput);
|
||||||
expect(sideEffectTarget).bignumber.to.be.eq(randomInput);
|
expect(sideEffectTarget).bignumber.to.be.eq(randomInput);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the after function with the provided arguments', async () => {
|
it('should call the after function with the provided arguments', async () => {
|
||||||
let sideEffectTarget = ZERO;
|
let sideEffectTarget = ZERO_AMOUNT;
|
||||||
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
|
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
|
||||||
before: async (input: BigNumber) => {},
|
before: async (input: BigNumber) => {},
|
||||||
after: async (beforeInfo: any, result: Result, input: BigNumber) => {
|
after: async (beforeInfo: any, result: Result, input: BigNumber) => {
|
||||||
sideEffectTarget = input;
|
sideEffectTarget = input;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const randomInput = getRandomInteger(ZERO, MAX_UINT256);
|
const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256);
|
||||||
await assertion.runAsync(randomInput);
|
await assertion.runAsync(randomInput);
|
||||||
expect(sideEffectTarget).bignumber.to.be.eq(randomInput);
|
expect(sideEffectTarget).bignumber.to.be.eq(randomInput);
|
||||||
});
|
});
|
||||||
@ -63,8 +62,8 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should pass the return value of "before" to "after"', async () => {
|
it('should pass the return value of "before" to "after"', async () => {
|
||||||
const randomInput = getRandomInteger(ZERO, MAX_UINT256);
|
const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256);
|
||||||
let sideEffectTarget = constants.ZERO_AMOUNT;
|
let sideEffectTarget = ZERO_AMOUNT;
|
||||||
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
|
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
|
||||||
before: async (input: BigNumber) => {
|
before: async (input: BigNumber) => {
|
||||||
return randomInput;
|
return randomInput;
|
||||||
@ -78,14 +77,14 @@ blockchainTests.resets('FunctionAssertion Unit Tests', env => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should pass the result from the function call to "after"', async () => {
|
it('should pass the result from the function call to "after"', async () => {
|
||||||
let sideEffectTarget = constants.ZERO_AMOUNT;
|
let sideEffectTarget = ZERO_AMOUNT;
|
||||||
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
|
const assertion = new FunctionAssertion(exampleContract.returnInteger, {
|
||||||
before: async (input: BigNumber) => {},
|
before: async (input: BigNumber) => {},
|
||||||
after: async (beforeInfo: any, result: Result, input: BigNumber) => {
|
after: async (beforeInfo: any, result: Result, input: BigNumber) => {
|
||||||
sideEffectTarget = result.data;
|
sideEffectTarget = result.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const randomInput = getRandomInteger(ZERO, MAX_UINT256);
|
const randomInput = getRandomInteger(ZERO_AMOUNT, MAX_UINT256);
|
||||||
await assertion.runAsync(randomInput);
|
await assertion.runAsync(randomInput);
|
||||||
expect(sideEffectTarget).bignumber.to.be.eq(randomInput);
|
expect(sideEffectTarget).bignumber.to.be.eq(randomInput);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user