using awaits for proper result

pull/5370/head
lianahus 4 years ago committed by Liana Husikyan
parent f27416552b
commit 7ea41d7288
  1. 6
      apps/remix-ide/src/app/tabs/test-tab.js
  2. 5
      apps/remix-ide/src/app/tabs/testTab/testTab.js

@ -606,7 +606,7 @@ module.exports = class TestTab extends ViewPlugin {
this.updateDirList(testDirInput)
} else {
// If there is no matching folder in the workspace with entered text, enable Create button
if (this.testTabLogic.pathExists(testDirInput)) {
if (await this.testTabLogic.pathExists(testDirInput)) {
this.createTestFolder.disabled = true
this.updateGenerateFileAction().disabled = false
} else {
@ -636,10 +636,10 @@ module.exports = class TestTab extends ViewPlugin {
name="utPath"
style="background-image: var(--primary);"
onkeyup=${(e) => this.handleTestDirInput(e)}
onchange=${(e) => {
onchange=${async (e) => {
if (this.createTestFolder.disabled) {
this.inputPath.value = this.trimTestDirInput(this.inputPath.value)
if (this.testTabLogic.pathExists(this.inputPath.value)) {
if (await this.testTabLogic.pathExists(this.inputPath.value)) {
this.inputPath.value = this.trimTestDirInput(this.inputPath.value)
this.testTabLogic.setCurrentPath(this.inputPath.value)
this.updateForNewCurrent()

@ -23,11 +23,12 @@ class TestTabLogic {
})
}
pathExists (path) {
async pathExists (path) {
// Checking to ignore the value which contains only whitespaces
if (!path || !(/\S/.test(path))) return
const fileProvider = this.fileManager.fileProviderOf(path.split('/')[0])
return fileProvider.exists(path, (e, res) => { return res })
const res = await fileProvider.exists(path, (e, res) => { return res })
return res
}
generateTestFile () {

Loading…
Cancel
Save