fix lost refs while rebasing

pull/3094/head
yann300 6 years ago
parent 3f968e6d6d
commit 0358b46cc4
  1. 1
      src/app.js
  2. 1
      src/app/files/fileManager.js
  3. 34
      src/app/tabs/test-tab.js

@ -474,6 +474,7 @@ Please make a backup of your contracts and start using http://remix.ethereum.org
self._components.filePanel = new FilePanel() self._components.filePanel = new FilePanel()
self._view.leftpanel.appendChild(self._components.filePanel.render()) self._view.leftpanel.appendChild(self._components.filePanel.render())
self._components.filePanel.event.register('resize', delta => self._adjustLayout('left', delta)) self._components.filePanel.event.register('resize', delta => self._adjustLayout('left', delta))
registry.put({api: self._components.filePanel, name: 'filepanel'})
// ----------------- Renderer ----------------- // ----------------- Renderer -----------------
var renderer = new Renderer() var renderer = new Renderer()

@ -154,6 +154,7 @@ class FileManager {
} }
fileProviderOf (file) { fileProviderOf (file) {
if (!file) return null
var provider = file.match(/[^/]*/) var provider = file.match(/[^/]*/)
if (provider !== null && this._deps.filesProviders[provider[0]]) { if (provider !== null && this._deps.filesProviders[provider[0]]) {
return this._deps.filesProviders[provider[0]] return this._deps.filesProviders[provider[0]]

@ -13,23 +13,16 @@ module.exports = class TestTab {
// dependencies // dependencies
self._deps = { self._deps = {
fileManager: self._components.registry.get('filemanager').api, fileManager: self._components.registry.get('filemanager').api,
app: self._components.registry.get('app').api app: self._components.registry.get('app').api,
filePanel: self._components.registry.get('filepanel').api
} }
self.data = {} self.data = {}
self._view.el = self.render()
self._deps.app.event.register('tabChanged', tabName => {
if (tabName !== 'test') return
yo.update(self._view.el, self.render())
self._view.el.style.display = 'block'
})
return { render () { return self._view.el } }
} }
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} hidden='true' id="tests"></div>`
var testsSummary = yo`<div class=${css.container} hidden='true' id="tests"></div>` var testsSummary = yo`<div class=${css.container} hidden='true' id="tests"></div>`
self.data.allTests = getTests() self.data.allTests = getTests(self)
self.data.selectedTests = [...self.data.allTests] self.data.selectedTests = [...self.data.allTests]
var testCallback = function (result) { var testCallback = function (result) {
@ -61,28 +54,27 @@ module.exports = class TestTab {
testsSummary.appendChild(yo`<div>${result.totalFailing} failing</div>`) testsSummary.appendChild(yo`<div>${result.totalFailing} failing</div>`)
} }
result.errors.forEach((error, index) => { result.errors.forEach((error, index) => {
testsSummary.appendChild(yo`<div>${index + 1} ${error.context}} ${error.value} </div>`) testsSummary.appendChild(yo`<div>${error.context}: ${error.value} </div>`)
testsSummary.appendChild(yo`<div></div>`)
testsSummary.appendChild(yo`<div>error: ${error.message}</div>`) testsSummary.appendChild(yo`<div>error: ${error.message}</div>`)
}) })
} }
function runTest (testFilePath, provider, callback) { function runTest (testFilePath, callback) {
provider.get(testFilePath, (error, content) => { self._deps.fileManager.fileProviderOf(testFilePath).get(testFilePath, (error, content) => {
if (!error) { if (!error) {
var runningTest = {} var runningTest = {}
runningTest[testFilePath] = { content } runningTest[testFilePath] = { content }
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) => { this._deps.app.importFileCb(url, cb) }) }, (url, cb) => { self._deps.app.importFileCb(url, cb) })
} }
}) })
} }
function getTests () { function getTests (self) {
var path = this._deps.fileManager.currentPath() var path = self._deps.fileManager.currentPath()
var provider = this._deps.fileManager.fileProviderOf(path) var provider = self._deps.fileManager.fileProviderOf(path)
var tests = [] var tests = []
self._deps.fileManager.filesFromPath(path, (error, files) => { self._deps.fileManager.filesFromPath(path, (error, files) => {
if (!error) { if (!error) {
@ -94,7 +86,7 @@ module.exports = class TestTab {
return tests return tests
} }
self._events.filePanel.register('newTestFileCreated', file => { self._deps.filePanel.event.register('newTestFileCreated', file => {
var testList = document.querySelector("[class^='testList']") var testList = document.querySelector("[class^='testList']")
var test = yo`<label><input onchange =${(e) => toggleCheckbox(e, file)} type="checkbox" checked="true">${file} </label>` var test = yo`<label><input onchange =${(e) => toggleCheckbox(e, file)} type="checkbox" checked="true">${file} </label>`
testList.appendChild(test) testList.appendChild(test)
@ -102,6 +94,9 @@ module.exports = class TestTab {
self.data.selectedTests.push(file) self.data.selectedTests.push(file)
}) })
self._deps.fileManager.event.register('currentFileChanged', (file, provider) => {
})
// self._events.filePanel.register('fileRenamed', (oldName, newName, isFolder) => { // self._events.filePanel.register('fileRenamed', (oldName, newName, isFolder) => {
// debugger // debugger
// self.data.allTests = self.data.allTests.filter(e => e != oldName) // self.data.allTests = self.data.allTests.filter(e => e != oldName)
@ -144,6 +139,7 @@ module.exports = class TestTab {
</div> </div>
</div> </div>
` `
if (!self._view.el) self._view.el = el
return el return el
} }
} }

Loading…
Cancel
Save