From c32ef28b37d24a7f093a8104a424e4b91afea3cb Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Sat, 19 May 2018 10:14:53 -0400 Subject: [PATCH] update runTestSources to use callbacks --- src/app/tabs/test-tab.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index 319ee364cb..d759f3e278 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -3,9 +3,46 @@ var css = require('./styles/test-tab-styles') var remixTests = require('remix-tests') function testTabView (api) { + let testCallback = function (result) { + if (result.type === 'contract') { + console.log('\n ' + result.value) + } else if (result.type === 'testPass') { + console.log('\t✓ ' + result.value) + } else if (result.type === 'testFailure') { + console.log('\t✘ ' + result.value) + } + } + + let resultsCallback = function (_err, result, cb) { + console.dir(result) + console.dir('testName ' + result.context) + console.dir(result.passingNum) + console.dir(result.failureNum) + console.dir(result.timePassed) + cb() + } + + let finalCallback = function (_err, result) { + console.dir('finalCallback') + + if (result.totalPassing > 0) { + console.log((' ' + result.totalPassing + ' passing ') + ('(' + result.totalTime + 's)')) + } + if (result.totalFailing > 0) { + console.log((' ' + result.totalFailing + ' failing')) + } + + result.errors.forEach((error, index) => { + console.log(' ' + (index + 1) + ') ' + error.context + ' ' + error.value) + console.log('') + console.log(('\t error: ' + error.message)) + }) + } + let runTests = function () { let contractSources = api.getAllSources() - remixTests.runTestSources(contractSources) + + remixTests.runTestSources(contractSources, testCallback, resultsCallback, finalCallback) } return yo`