|
|
@ -35,17 +35,17 @@ module.exports = class TestTab { |
|
|
|
} |
|
|
|
} |
|
|
|
render () { |
|
|
|
render () { |
|
|
|
const self = this |
|
|
|
const self = this |
|
|
|
var testsOutput = yo`<div class=${css.container} hidden='true' id="tests"></div>` |
|
|
|
var testsOutput = yo`<div class="${css.container} border border-primary border-right-0 border-left-0 border-bottom-0" hidden='true' id="tests"></div>` |
|
|
|
var testsSummary = yo`<div class=${css.container} hidden='true' id="tests"></div>` |
|
|
|
var testsSummary = yo`<div class="${css.container} border border-primary border-right-0 border-left-0 border-bottom-0" hidden='true' id="tests"></div>` |
|
|
|
|
|
|
|
|
|
|
|
var testCallback = function (result) { |
|
|
|
var testCallback = function (result) { |
|
|
|
testsOutput.hidden = false |
|
|
|
testsOutput.hidden = false |
|
|
|
if (result.type === 'contract') { |
|
|
|
if (result.type === 'contract') { |
|
|
|
testsOutput.appendChild(yo`<div class=${css.outputTitle}>${result.filename} (${result.value})</div>`) |
|
|
|
testsOutput.appendChild(yo`<div class="${css.outputTitle}">${result.filename} (${result.value})</div>`) |
|
|
|
} else if (result.type === 'testPass') { |
|
|
|
} else if (result.type === 'testPass') { |
|
|
|
testsOutput.appendChild(yo`<div class='${css.testPass} ${css.testLog}'>✓ (${result.value})</div>`) |
|
|
|
testsOutput.appendChild(yo`<div class="${css.testPass} ${css.testLog} bg-success">✓ (${result.value})</div>`) |
|
|
|
} else if (result.type === 'testFailure') { |
|
|
|
} else if (result.type === 'testFailure') { |
|
|
|
testsOutput.appendChild(yo`<div class='${css.testFailure} ${css.testLog}'>✘ (${result.value})</div>`) |
|
|
|
testsOutput.appendChild(yo`<div class="${css.testFailure} ${css.testLog} bg-danger">✘ (${result.value})</div>`) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -60,21 +60,21 @@ module.exports = class TestTab { |
|
|
|
var updateFinalResult = function (_err, result, filename) { |
|
|
|
var updateFinalResult = function (_err, result, filename) { |
|
|
|
testsSummary.hidden = false |
|
|
|
testsSummary.hidden = false |
|
|
|
if (_err) { |
|
|
|
if (_err) { |
|
|
|
testsSummary.appendChild(yo`<div class=${css.testFailureSummary} >${_err.message}</div>`) |
|
|
|
testsSummary.appendChild(yo`<div class="${css.testFailureSummary} text-danger" >${_err.message}</div>`) |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
testsSummary.appendChild(yo`<div class=${css.summaryTitle}> ${filename} </div>`) |
|
|
|
testsSummary.appendChild(yo`<div class=${css.summaryTitle}> ${filename} </div>`) |
|
|
|
if (result.totalPassing > 0) { |
|
|
|
if (result.totalPassing > 0) { |
|
|
|
testsSummary.appendChild(yo`<div>${result.totalPassing} passing (${result.totalTime}s)</div>`) |
|
|
|
testsSummary.appendChild(yo`<div class="text-success">${result.totalPassing} passing (${result.totalTime}s)</div>`) |
|
|
|
testsSummary.appendChild(yo`<br>`) |
|
|
|
testsSummary.appendChild(yo`<br>`) |
|
|
|
} |
|
|
|
} |
|
|
|
if (result.totalFailing > 0) { |
|
|
|
if (result.totalFailing > 0) { |
|
|
|
testsSummary.appendChild(yo`<div>${result.totalFailing} failing</div>`) |
|
|
|
testsSummary.appendChild(yo`<div class="text-danger" >${result.totalFailing} failing</div>`) |
|
|
|
testsSummary.appendChild(yo`<br>`) |
|
|
|
testsSummary.appendChild(yo`<br>`) |
|
|
|
} |
|
|
|
} |
|
|
|
result.errors.forEach((error, index) => { |
|
|
|
result.errors.forEach((error, index) => { |
|
|
|
testsSummary.appendChild(yo`<div>${error.context} - ${error.value} </div>`) |
|
|
|
testsSummary.appendChild(yo`<div class="text-danger" >${error.context} - ${error.value} </div>`) |
|
|
|
testsSummary.appendChild(yo`<div class=${css.testFailureSummary} >${error.message}</div>`) |
|
|
|
testsSummary.appendChild(yo`<div class="${css.testFailureSummary} text-danger" >${error.message}</div>`) |
|
|
|
testsSummary.appendChild(yo`<br>`) |
|
|
|
testsSummary.appendChild(yo`<br>`) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -87,7 +87,7 @@ module.exports = class TestTab { |
|
|
|
remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => { |
|
|
|
remixTests.runTestSources(runningTest, testCallback, resultsCallback, (error, result) => { |
|
|
|
updateFinalResult(error, result, testFilePath) |
|
|
|
updateFinalResult(error, result, testFilePath) |
|
|
|
callback(error) |
|
|
|
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 () { |
|
|
|
var runTests = function () { |
|
|
|
testsOutput.innerHTML = '' |
|
|
|
testsOutput.innerHTML = 'Running tests ...' |
|
|
|
testsSummary.innerHTML = '' |
|
|
|
|
|
|
|
var tests = self.data.selectedTests |
|
|
|
var tests = self.data.selectedTests |
|
|
|
async.eachOfSeries(tests, (value, key, callback) => { runTest(value, callback) }) |
|
|
|
async.eachOfSeries(tests, (value, key, callback) => { runTest(value, callback) }) |
|
|
|
} |
|
|
|
} |
|
|
@ -194,9 +193,9 @@ module.exports = class TestTab { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var el = yo` |
|
|
|
var el = yo` |
|
|
|
<div class="${css.testTabView}" id="testView"> |
|
|
|
<div class="${css.testTabView} card" id="testView"> |
|
|
|
<div class="${css.infoBox}"> |
|
|
|
<div class="${css.infoBox}"> |
|
|
|
<div class="${css.title}">Unit Testing</div> |
|
|
|
<h2 class="${css.title}">Unit Testing</h2> |
|
|
|
Test your smart contract by creating a foo_test.sol file (open ballot_test.sol to see the example). |
|
|
|
Test your smart contract by creating a foo_test.sol file (open ballot_test.sol to see the example). |
|
|
|
<br/> |
|
|
|
<br/> |
|
|
|
You will find more informations in the <a href="https://remix.readthedocs.io/en/latest/unittesting_tab.html">documentation</a> |
|
|
|
You will find more informations in the <a href="https://remix.readthedocs.io/en/latest/unittesting_tab.html">documentation</a> |
|
|
@ -205,12 +204,13 @@ module.exports = class TestTab { |
|
|
|
<br/> |
|
|
|
<br/> |
|
|
|
For more details, see |
|
|
|
For more details, see |
|
|
|
How to test smart contracts guide in our documentation. |
|
|
|
How to test smart contracts guide in our documentation. |
|
|
|
<div class="${css.generateTestFile}" onclick="${generateTestFile}">Generate test file</div> |
|
|
|
<br/> |
|
|
|
|
|
|
|
<button class="${css.generateTestFile} btn btn-primary m-1" onclick="${generateTestFile}">Generate test file</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="${css.tests}"> |
|
|
|
<div class="${css.tests}"> |
|
|
|
${self.testList} |
|
|
|
${self.testList} |
|
|
|
<div class="${css.buttons}"> |
|
|
|
<div class="${css.buttons} btn-group"> |
|
|
|
<div class="${css.runButton}" onclick="${runTests}">Run Tests</div> |
|
|
|
<button class="${css.runButton} btn btn-primary m-1" onclick="${runTests}">Run Tests</button> |
|
|
|
<label class="${css.label}" for="checkAllTests"> |
|
|
|
<label class="${css.label}" for="checkAllTests"> |
|
|
|
<input id="checkAllTests" |
|
|
|
<input id="checkAllTests" |
|
|
|
type="checkbox" |
|
|
|
type="checkbox" |
|
|
|