Commit 8d6abf3c authored by Iuri Matias's avatar Iuri Matias Committed by yann300

move get tests to test tab logic

parent fc40e5f9
...@@ -41,7 +41,7 @@ module.exports = class TestTab extends ApiFactory { ...@@ -41,7 +41,7 @@ module.exports = class TestTab extends ApiFactory {
}) })
this.fileManager.event.register('currentFileChanged', (file, provider) => { this.fileManager.event.register('currentFileChanged', (file, provider) => {
this.getTests((error, tests) => { this.testTabLogic.getTests((error, tests) => {
if (error) return tooltip(error) if (error) return tooltip(error)
this.data.allTests = tests this.data.allTests = tests
this.data.selectedTests = [...this.data.allTests] this.data.selectedTests = [...this.data.allTests]
...@@ -59,21 +59,6 @@ module.exports = class TestTab extends ApiFactory { ...@@ -59,21 +59,6 @@ module.exports = class TestTab extends ApiFactory {
}) })
} }
getTests (cb) {
var path = this.fileManager.currentPath()
if (!path) return cb(null, [])
var provider = this.fileManager.fileProviderOf(path)
if (!provider) return cb(null, [])
var tests = []
this.fileManager.filesFromPath(path, (error, files) => {
if (error) return cb(error)
for (var file in files) {
if (/.(_test.sol)$/.exec(file)) tests.push(provider.type + '/' + file)
}
cb(null, tests)
})
}
listTests () { listTests () {
return this.data.allTests.map(test => yo`<label class="singleTestLabel"><input class="singleTest" onchange =${(e) => this.toggleCheckbox(e.target.checked, test)} type="checkbox" checked="true">${test} </label>`) return this.data.allTests.map(test => yo`<label class="singleTestLabel"><input class="singleTest" onchange =${(e) => this.toggleCheckbox(e.target.checked, test)} type="checkbox" checked="true">${test} </label>`)
} }
......
...@@ -18,6 +18,21 @@ class TestTabLogic { ...@@ -18,6 +18,21 @@ class TestTabLogic {
}) })
} }
getTests (cb) {
var path = this.fileManager.currentPath()
if (!path) return cb(null, [])
var provider = this.fileManager.fileProviderOf(path)
if (!provider) return cb(null, [])
var tests = []
this.fileManager.filesFromPath(path, (error, files) => {
if (error) return cb(error)
for (var file in files) {
if (/.(_test.sol)$/.exec(file)) tests.push(provider.type + '/' + file)
}
cb(null, tests)
})
}
generateTestContractSample () { generateTestContractSample () {
return `pragma solidity >=0.4.0 <0.6.0; return `pragma solidity >=0.4.0 <0.6.0;
import "remix_tests.sol"; // this import is automatically injected by Remix. import "remix_tests.sol"; // this import is automatically injected by Remix.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment