diff --git a/remix-tests/src/compiler.ts b/remix-tests/src/compiler.ts index 60a500f8dd..ff6d3a3854 100644 --- a/remix-tests/src/compiler.ts +++ b/remix-tests/src/compiler.ts @@ -67,7 +67,7 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts: }, function doCompilation(next: Function) { // @ts-ignore - compiler.event.register('compilationFinished', this, function (success, data, source) { + compiler.event.register('compilationFinished', this, (success, data, source) => { next(null, data) }) compiler.compile(sources, filepath) @@ -83,8 +83,8 @@ export function compileFileOrFiles(filename: string, isDirectory: boolean, opts: } } -export function compileContractSources(sources: SrcIfc, importFileCb, opts, cb) { - let compiler, filepath +export function compileContractSources(sources: SrcIfc, importFileCb: any, opts: any, cb: Function) { + let compiler, filepath: string let accounts = opts.accounts || [] // Iterate over sources keys. Inject test libraries. Inject test library import statements. if (!('remix_tests.sol' in sources) && !('tests.sol' in sources)) { @@ -110,7 +110,7 @@ export function compileContractSources(sources: SrcIfc, importFileCb, opts, cb) }, function doCompilation (next: Function) { // @ts-ignore - compiler.event.register('compilationFinished', this, function (success, data, source) { + compiler.event.register('compilationFinished', this, (success, data, source) => { next(null, data) }) compiler.compile(sources, filepath) diff --git a/remix-tests/src/index.ts b/remix-tests/src/index.ts index 2ac9a00233..aad3269514 100644 --- a/remix-tests/src/index.ts +++ b/remix-tests/src/index.ts @@ -1,10 +1,5 @@ -import { runTestFiles } from './runTestFiles' -import { runTestSources } from './runTestSources' -import { runTest } from './testRunner' - -module.exports = { - runTestFiles: runTestFiles, - runTestSources: runTestSources, - runTest: runTest, - assertLibCode: require('../sol/tests.sol.js') -} +export { runTestFiles } from './runTestFiles' +export { runTestSources } from './runTestSources' +export { runTest } from './testRunner' +export * from './types' +export { assertLibCode } from '../sol/tests.sol.js' diff --git a/remix-tests/src/testRunner.ts b/remix-tests/src/testRunner.ts index dbfe7646e4..de044de78e 100644 --- a/remix-tests/src/testRunner.ts +++ b/remix-tests/src/testRunner.ts @@ -3,7 +3,7 @@ import * as changeCase from 'change-case' import Web3 from 'web3' import { RunListInterface, TestCbInterface, TestResultInterface, ResultCbInterface } from './types' -function getFunctionFullName (signature, methodIdentifiers) { +function getFunctionFullName (signature: string, methodIdentifiers) { for (var method in methodIdentifiers) { if (signature.replace('0x', '') === methodIdentifiers[method].replace('0x', '')) { return method @@ -12,7 +12,7 @@ function getFunctionFullName (signature, methodIdentifiers) { return null } -function getOverridedSender (userdoc, signature, methodIdentifiers) { +function getOverridedSender (userdoc, signature: string, methodIdentifiers) { let fullName: any = getFunctionFullName(signature, methodIdentifiers) let match = /sender: account-+(\d)/g let accountIndex = userdoc.methods[fullName] ? match.exec(userdoc.methods[fullName].notice) : null @@ -28,7 +28,7 @@ function getTestFunctions (jsonInterface) { return jsonInterface.filter((x) => specialFunctions.indexOf(x.name) < 0 && x.type === 'function') } -function createRunList(jsonInterface): RunListInterface[] { +function createRunList (jsonInterface): RunListInterface[] { let availableFunctions = getAvailableFunctions(jsonInterface) let testFunctions = getTestFunctions(jsonInterface) let runList: RunListInterface[] = [] @@ -54,7 +54,7 @@ function createRunList(jsonInterface): RunListInterface[] { return runList } -export function runTest(testName, testObject: any, contractDetails: any, opts: any, testCallback: TestCbInterface, resultsCallback: ResultCbInterface) { +export function runTest (testName, testObject: any, contractDetails: any, opts: any, testCallback: TestCbInterface, resultsCallback: ResultCbInterface) { let runList = createRunList(testObject._jsonInterface) let passingNum: number = 0 diff --git a/remix-tests/tests/testRunner.ts b/remix-tests/tests/testRunner.ts index b467e106c5..65e8488cf8 100644 --- a/remix-tests/tests/testRunner.ts +++ b/remix-tests/tests/testRunner.ts @@ -5,8 +5,8 @@ import { Provider } from 'remix-simulator' import { compileFileOrFiles } from '../dist/compiler' import { deployAll } from '../dist/deployer' -import { runTest } from '../dist/testRunner' -import { ResultsInterface, TestCbInterface, ResultCbInterface } from '../dist/types' +import { runTest } from '../dist/index' +import { ResultsInterface, TestCbInterface, ResultCbInterface } from '../dist/index' function compileAndDeploy(filename: string, callback: Function) { let web3: Web3 = new Web3() @@ -119,7 +119,7 @@ describe('testRunner', () => { let tests: any[] = [], results: ResultsInterface; before(function (done) { - compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) { + compileAndDeploy(filename, (_err, compilationData, contracts, accounts) => { var testCallback: TestCbInterface = (err, test) => { if (err) { throw err } tests.push(test) @@ -158,7 +158,7 @@ describe('testRunner', () => { let tests: any[] = [], results: ResultsInterface; before(function (done) { - compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) { + compileAndDeploy(filename, (_err, compilationData, contracts, accounts) => { var testCallback: TestCbInterface = (err, test) => { if (err) { throw err } tests.push(test) @@ -186,7 +186,7 @@ describe('testRunner', () => { let tests: any[] = [], results: ResultsInterface; before(function (done) { - compileAndDeploy(filename, function (_err, compilationData, contracts, accounts) { + compileAndDeploy(filename, (_err, compilationData, contracts, accounts) => { var testCallback: TestCbInterface = (err, test) => { if (err) { throw err } tests.push(test)