diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-11 23:38:51 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-14 16:35:13 +0800 |
commit | b74957acdfc8d67d154bcb4698acd7575db7cc47 (patch) | |
tree | 3f33c2faac3b55e52098ab0b5b9883a9b62f5aee /packages/sra-report | |
parent | 6aed4fb1ae27dabed027c855f2cbdc0bfb4f3b6b (diff) | |
download | dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.gz dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.bz2 dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.lz dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.xz dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.tar.zst dexon-sol-tools-b74957acdfc8d67d154bcb4698acd7575db7cc47.zip |
Add missing type definitions
Diffstat (limited to 'packages/sra-report')
-rw-r--r-- | packages/sra-report/src/postman_environment_factory.ts | 31 | ||||
-rw-r--r-- | packages/sra-report/test/test_runner.ts | 13 |
2 files changed, 32 insertions, 12 deletions
diff --git a/packages/sra-report/src/postman_environment_factory.ts b/packages/sra-report/src/postman_environment_factory.ts index 530cacb07..42389aea2 100644 --- a/packages/sra-report/src/postman_environment_factory.ts +++ b/packages/sra-report/src/postman_environment_factory.ts @@ -12,8 +12,22 @@ import { addresses as ropstenAddresses } from './contract_addresses/ropsten_addr const ENVIRONMENT_NAME = 'SRA Report'; -interface EnvironmentValue { +export interface EnvironmentValue { key: string; + value: string; + enabled: true; + type: 'text'; +} + +export interface Environment { + name: string; + values: EnvironmentValue[]; +} + +export interface Addresses { + WETH: string; + ZRX: string; + EXCHANGE: string; } export const postmanEnvironmentFactory = { @@ -25,7 +39,7 @@ export const postmanEnvironmentFactory = { * - Contract addresses based on the network id for making specific queries (ex. baseTokenAddress=ZRX_address) * - Order properties for making specific queries (ex. maker=orderMaker) */ - async createPostmanEnvironmentAsync(url: string, networkId: number) { + async createPostmanEnvironmentAsync(url: string, networkId: number): Promise<Environment> { const orderEnvironmentValues = await createOrderEnvironmentValuesAsync(url); const allEnvironmentValues = _.concat( createSchemaEnvironmentValues(), @@ -40,7 +54,7 @@ export const postmanEnvironmentFactory = { return environment; }, }; -function createSchemaEnvironmentValues() { +function createSchemaEnvironmentValues(): EnvironmentValue[] { const schemas: Schema[] = _.values(schemasByName); const schemaEnvironmentValues = _.compact( _.map(schemas, (schema: Schema) => { @@ -60,7 +74,7 @@ function createSchemaEnvironmentValues() { const result = _.concat(schemaEnvironmentValues, createEnvironmentValue('schemaKeys', JSON.stringify(schemaKeys))); return result; } -function createContractAddressEnvironmentValues(networkId: number) { +function createContractAddressEnvironmentValues(networkId: number): EnvironmentValue[] { const contractAddresses = getContractAddresses(networkId); return [ createEnvironmentValue('tokenContractAddress1', contractAddresses.WETH), @@ -68,7 +82,7 @@ function createContractAddressEnvironmentValues(networkId: number) { createEnvironmentValue('exchangeContractAddress', contractAddresses.EXCHANGE), ]; } -async function createOrderEnvironmentValuesAsync(url: string) { +async function createOrderEnvironmentValuesAsync(url: string): Promise<EnvironmentValue[]> { const httpClient = new HttpClient(url); const orders = await httpClient.getOrdersAsync(); const orderIfExists = _.head(orders); @@ -91,7 +105,7 @@ async function createOrderEnvironmentValuesAsync(url: string) { ]; } } -function getContractAddresses(networkId: number) { +function getContractAddresses(networkId: number): Addresses { switch (networkId) { case 1: return mainnetAddresses; @@ -105,7 +119,7 @@ function getContractAddresses(networkId: number) { throw new Error('Unsupported network id'); } } -function convertSchemaIdToKey(schemaId: string) { +function convertSchemaIdToKey(schemaId: string): string { let result = schemaId; if (_.startsWith(result, '/')) { result = result.substr(1); @@ -113,7 +127,8 @@ function convertSchemaIdToKey(schemaId: string) { result = `${result}Schema`; return result; } -function createEnvironmentValue(key: string, value: string) { + +function createEnvironmentValue(key: string, value: string): EnvironmentValue { return { key, value, diff --git a/packages/sra-report/test/test_runner.ts b/packages/sra-report/test/test_runner.ts index bf9b923e7..91ef6aa4e 100644 --- a/packages/sra-report/test/test_runner.ts +++ b/packages/sra-report/test/test_runner.ts @@ -3,7 +3,12 @@ import * as chaiAsPromised from 'chai-as-promised'; import * as dirtyChai from 'dirty-chai'; import * as _ from 'lodash'; import 'mocha'; -import { NewmanRunExecution, NewmanRunExecutionAssertion, NewmanRunSummary } from 'newman'; +import { + NewmanRunExecution, + NewmanRunExecutionAssertion, + NewmanRunExecutionAssertionError, + NewmanRunSummary, +} from 'newman'; import * as nock from 'nock'; import * as sraReportCollectionJSON from '../../postman_collections/sra_report.postman_collection.json'; @@ -33,7 +38,7 @@ export const testRunner = { nockInterceptor: nock.Interceptor, postmanCollectionFolderName: string, postmanCollectionRequestName: string, - ) { + ): void { const newmanRunOptions = { ...baseNewmanRunOptions, folder: postmanCollectionFolderName, @@ -87,7 +92,7 @@ export const testRunner = { postmanCollectionRequestName: string, malformedJson: object, correctJson: object, - ) { + ): void { const newmanRunOptions = { ...baseNewmanRunOptions, folder: postmanCollectionFolderName, @@ -116,7 +121,7 @@ function findAssertionErrorIfExists( summary: NewmanRunSummary, postmanCollectionRequestName: string, postmanCollectionAssertionName: string, -) { +): NewmanRunExecutionAssertionError | undefined { const matchingExecutionIfExists = _.find(summary.run.executions, (execution: NewmanRunExecution) => { return execution.item.name === postmanCollectionRequestName; }); |