fix testTabLogic

pull/5370/head
Aniket-Engg 3 years ago committed by Aniket
parent 14c2acb723
commit 3c19efa05f
  1. 5
      apps/remix-ide/src/app/tabs/test-tab.js
  2. 1
      libs/remix-ui/solidity-unit-testing/src/index.ts
  3. 2
      libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts
  4. 11
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx

@ -2,6 +2,7 @@
import React from 'react' // eslint-disable-line import React from 'react' // eslint-disable-line
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import { SolidityUnitTesting } from '@remix-ui/solidity-unit-testing' // eslint-disable-line import { SolidityUnitTesting } from '@remix-ui/solidity-unit-testing' // eslint-disable-line
import { TestTabLogic } from '@remix-ui/solidity-unit-testing' // eslint-disable-line
import { ViewPlugin } from '@remixproject/engine-web' import { ViewPlugin } from '@remixproject/engine-web'
import helper from '../../lib/helper' import helper from '../../lib/helper'
@ -16,7 +17,7 @@ var { UnitTestRunner, assertLibCode } = require('@remix-project/remix-tests')
const _paq = window._paq = window._paq || [] const _paq = window._paq = window._paq || []
const TestTabLogic = require('./testTab/testTab') // const TestTabLogic = require('./testTab/testTab')
const profile = { const profile = {
name: 'solidityUnitTesting', name: 'solidityUnitTesting',
@ -41,6 +42,7 @@ module.exports = class TestTab extends ViewPlugin {
this.appManager = appManager this.appManager = appManager
this.renderer = new Renderer(this) this.renderer = new Renderer(this)
this.testRunner = new UnitTestRunner() this.testRunner = new UnitTestRunner()
this.testTabLogic = new TestTabLogic(this.fileManager, helper)
this.hasBeenStopped = false this.hasBeenStopped = false
this.runningTestsNumber = 0 this.runningTestsNumber = 0
this.readyTestsNumber = 0 this.readyTestsNumber = 0
@ -61,7 +63,6 @@ module.exports = class TestTab extends ViewPlugin {
} }
onActivationInternal () { onActivationInternal () {
this.testTabLogic = new TestTabLogic(this.fileManager)
this.listenToEvents() this.listenToEvents()
this.call('filePanel', 'registerContextMenuItem', { this.call('filePanel', 'registerContextMenuItem', {
id: 'solidityUnitTesting', id: 'solidityUnitTesting',

@ -1 +1,2 @@
export * from './lib/solidity-unit-testing'; export * from './lib/solidity-unit-testing';
export * from './lib/logic/testTabLogic'

@ -38,7 +38,7 @@ export class TestTabLogic {
} }
generateTestFile () { generateTestFile () {
console.log('Inside generateTestFile-1SUT-') console.log('Inside generateTestFile-1SUT-currentFile-', this.fileManager.currentFile(), this.currentPath)
let fileName = this.fileManager.currentFile() let fileName = this.fileManager.currentFile()
const hasCurrent = !!fileName && this.fileManager.currentFile().split('.').pop().toLowerCase() === 'sol' const hasCurrent = !!fileName && this.fileManager.currentFile().split('.').pop().toLowerCase() === 'sol'
if (!hasCurrent) fileName = this.currentPath + '/newFile.sol' if (!hasCurrent) fileName = this.currentPath + '/newFile.sol'

@ -1,5 +1,5 @@
import React, { useState, useRef, useEffect } from 'react' // eslint-disable-line import React, { useState, useRef, useEffect } from 'react' // eslint-disable-line
import { TestTabLogic } from './logic/testTabLogic' // import { TestTabLogic } from './logic/testTabLogic'
var async = require('async') var async = require('async')
var ReactDOM = require('react-dom'); var ReactDOM = require('react-dom');
@ -17,7 +17,7 @@ export const SolidityUnitTesting = (props: any) => {
const {helper, testTab} = props const {helper, testTab} = props
const testTabLogic = new TestTabLogic(testTab.fileManager, helper) const { testTabLogic } = testTab
const [defaultPath, setDefaultPath] = useState('tests') const [defaultPath, setDefaultPath] = useState('tests')
const [disableCreateButton, setDisableCreateButton] = useState(true) const [disableCreateButton, setDisableCreateButton] = useState(true)
@ -106,13 +106,14 @@ export const SolidityUnitTesting = (props: any) => {
} }
const handleTestDirInput = async (e: any) => { const handleTestDirInput = async (e: any) => {
console.log('handleTestDirInput--e-->', e) console.log('handleTestDirInput--e-->', e.target)
let testDirInput = trimTestDirInput(inputPathValue) let testDirInput = trimTestDirInput(e.target.value)
console.log('handleTestDirInput--e-->', testDirInput)
testDirInput = helper.removeMultipleSlashes(testDirInput) testDirInput = helper.removeMultipleSlashes(testDirInput)
if (testDirInput !== '/') testDirInput = helper.removeTrailingSlashes(testDirInput) if (testDirInput !== '/') testDirInput = helper.removeTrailingSlashes(testDirInput)
setInputPathValue(testDirInput)
if (e.key === 'Enter') { if (e.key === 'Enter') {
setInputPathValue(testDirInput)
if (await testTabLogic.pathExists(testDirInput)) { if (await testTabLogic.pathExists(testDirInput)) {
testTabLogic.setCurrentPath(testDirInput) testTabLogic.setCurrentPath(testDirInput)
updateForNewCurrent() updateForNewCurrent()

Loading…
Cancel
Save