From fd2fbce7a366ed1da68e81f0d90e5608b531103d Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 25 Feb 2019 16:58:47 +0100 Subject: [PATCH] bootstrap unit testing --- src/app/tabs/styles/test-tab-styles.js | 11 -------- src/app/tabs/test-tab.js | 36 +++++++++++++------------- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/app/tabs/styles/test-tab-styles.js b/src/app/tabs/styles/test-tab-styles.js index 7a3c663a79..8eab2c9e0b 100644 --- a/src/app/tabs/styles/test-tab-styles.js +++ b/src/app/tabs/styles/test-tab-styles.js @@ -1,23 +1,18 @@ var csjs = require('csjs-inject') -var styleGuide = require('../../ui/styles-guide/theme-chooser') -var styles = styleGuide.chooser() var css = csjs` .testTabView {} .infoBox { - ${styles.rightPanel.testTab.box_listTests}; margin: 2%; } .tests {} .testList { - ${styles.rightPanel.testTab.box_listTests}; line-height: 2em; display: flex; flex-direction: column; margin: 2%; } .container { - ${styles.rightPanel.testTab.box_listTests}; margin: 2%; padding-bottom: 5%; } @@ -29,7 +24,6 @@ var css = csjs` font-weight: bold; } .testPass { - background-color: ${styles.rightPanel.testTab.color_testPass}; } .testLog { margin-bottom: 1%; @@ -37,22 +31,17 @@ var css = csjs` padding: 1% 1% 1% 5%; } .testFailure { - background-color: ${styles.rightPanel.testTab.color_testFail}; } .testFailureSummary { - color: ${styles.appProperties.errorText_Color}; } .buttons { - ${styles.rightPanel.testTab.box_listTests}; margin: 2%; display: flex; align-items: center; } .runButton { - ${styles.rightPanel.testTab.button_runTests}; } .generateTestFile { - ${styles.rightPanel.testTab.button_generateTestFile}; min-width: 100px } .title { diff --git a/src/app/tabs/test-tab.js b/src/app/tabs/test-tab.js index a3f63ebfc0..ff50aa331c 100644 --- a/src/app/tabs/test-tab.js +++ b/src/app/tabs/test-tab.js @@ -35,17 +35,17 @@ module.exports = class TestTab { } render () { const self = this - var testsOutput = yo`` - var testsSummary = yo`` + var testsOutput = yo`` + var testsSummary = yo`` var testCallback = function (result) { testsOutput.hidden = false if (result.type === 'contract') { - testsOutput.appendChild(yo`
${result.filename} (${result.value})
`) + testsOutput.appendChild(yo`
${result.filename} (${result.value})
`) } else if (result.type === 'testPass') { - testsOutput.appendChild(yo`
✓ (${result.value})
`) + testsOutput.appendChild(yo`
✓ (${result.value})
`) } else if (result.type === 'testFailure') { - testsOutput.appendChild(yo`
✘ (${result.value})
`) + testsOutput.appendChild(yo`
✘ (${result.value})
`) } } @@ -60,21 +60,21 @@ module.exports = class TestTab { var updateFinalResult = function (_err, result, filename) { testsSummary.hidden = false if (_err) { - testsSummary.appendChild(yo`
${_err.message}
`) + testsSummary.appendChild(yo`
${_err.message}
`) return } testsSummary.appendChild(yo`
${filename}
`) if (result.totalPassing > 0) { - testsSummary.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) + testsSummary.appendChild(yo`
${result.totalPassing} passing (${result.totalTime}s)
`) testsSummary.appendChild(yo`
`) } if (result.totalFailing > 0) { - testsSummary.appendChild(yo`
${result.totalFailing} failing
`) + testsSummary.appendChild(yo`
${result.totalFailing} failing
`) testsSummary.appendChild(yo`
`) } result.errors.forEach((error, index) => { - testsSummary.appendChild(yo`
${error.context} - ${error.value}
`) - testsSummary.appendChild(yo`
${error.message}
`) + testsSummary.appendChild(yo`
${error.context} - ${error.value}
`) + testsSummary.appendChild(yo`
${error.message}
`) testsSummary.appendChild(yo`
`) }) } @@ -87,7 +87,7 @@ module.exports = class TestTab { remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => { updateFinalResult(error, result, testFilePath) callback(error) - }, (url, cb) => { self.compileTab.importFileCb(url, cb) }) + }, (url, cb) => { self.compileTab.compileTabLogic.importFileCb(url, cb) }) } }) } @@ -171,8 +171,7 @@ module.exports = class TestTab { } var runTests = function () { - testsOutput.innerHTML = '' - testsSummary.innerHTML = '' + testsOutput.innerHTML = 'Running tests ...' var tests = self.data.selectedTests async.eachOfSeries(tests, (value, key, callback) => { runTest(value, callback) }) } @@ -194,9 +193,9 @@ module.exports = class TestTab { } var el = yo` -
+
-
Unit Testing
+

Unit Testing

Test your smart contract by creating a foo_test.sol file (open ballot_test.sol to see the example).
You will find more informations in the documentation @@ -205,12 +204,13 @@ module.exports = class TestTab {
For more details, see How to test smart contracts guide in our documentation. -
Generate test file
+
+
${self.testList} -
-
Run Tests
+
+