pull/1862/head
Aniket-Engg 3 years ago committed by Aniket
parent 9d425c0523
commit 8e88c92884
  1. 52
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx

@ -1,5 +1,6 @@
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')
import './css/style.css' import './css/style.css'
@ -30,9 +31,12 @@ export const SolidityUnitTesting = (props: any) => {
let [selectedTests, setSelectedTests] = useState([]) let [selectedTests, setSelectedTests] = useState([])
const [inputPathValue, setInputPathValue] = useState('tests') const [inputPathValue, setInputPathValue] = useState('tests')
const [readyTestsNumber, setReadyTestsNumber] = useState(0)
const [runningTestsNumber, setRunningTestsNumber] = useState(0) let [readyTestsNumber, setReadyTestsNumber] = useState(0)
const [hasBeenStopped, setHasBeenStopped] = useState(false) let [runningTestsNumber, setRunningTestsNumber] = useState(0)
let [hasBeenStopped, setHasBeenStopped] = useState(false)
let [areTestsRunning, setAreTestsRunning] = useState(false)
const trimTestDirInput = (input:string) => { const trimTestDirInput = (input:string) => {
@ -40,6 +44,16 @@ export const SolidityUnitTesting = (props: any) => {
else return input.trim() else return input.trim()
} }
const clearResults = () => {
console.log('clearResults--->')
// yo.update(this.resultStatistics, yo`<span></span>`)
// this.call('editor', 'clearAnnotations')
// this.testsOutput.innerHTML = ''
// this.testsOutput.hidden = true
// this.testsExecutionStopped.hidden = true
// this.testsExecutionStoppedError.hidden = true
}
const updateForNewCurrent = async (file = null) => { const updateForNewCurrent = async (file = null) => {
// Ensure that when someone clicks on compilation error and that opens a new file // Ensure that when someone clicks on compilation error and that opens a new file
// Test result, which is compilation error in this case, is not cleared // Test result, which is compilation error in this case, is not cleared
@ -55,8 +69,8 @@ export const SolidityUnitTesting = (props: any) => {
console.log('Inside updateForNewCurrent --allTests-->', allTests) console.log('Inside updateForNewCurrent --allTests-->', allTests)
allTests = [] allTests = []
updateTestFileList() updateTestFileList()
// this.clearResults() clearResults()
// if (!this.areTestsRunning) this.updateRunAction(file) if (!areTestsRunning) updateRunAction(file)
try { try {
testTabLogic.getTests((error: any, tests: any) => { testTabLogic.getTests((error: any, tests: any) => {
// if (error) return tooltip(error) // if (error) return tooltip(error)
@ -156,24 +170,22 @@ export const SolidityUnitTesting = (props: any) => {
const runTests = () => { const runTests = () => {
console.log('runtests--->') console.log('runtests--->')
// this.areTestsRunning = true areTestsRunning = true
// this.hasBeenStopped = false hasBeenStopped = false
// this.readyTestsNumber = 0 readyTestsNumber = 0
// this.runningTestsNumber = this.data.selectedTests.length runningTestsNumber = selectedTests.length
// const stopBtn = document.getElementById('runTestsTabStopAction') setDisableStopButton(false)
// stopBtn.removeAttribute('disabled') setDisableRunButton(true)
// const runBtn = document.getElementById('runTestsTabRunAction') clearResults()
// runBtn.setAttribute('disabled', 'disabled')
// this.clearResults()
// yo.update(this.resultStatistics, this.createResultLabel()) // yo.update(this.resultStatistics, this.createResultLabel())
// const tests = this.data.selectedTests const tests = selectedTests
// if (!tests) return if (!tests) return
// this.resultStatistics.hidden = tests.length === 0 // this.resultStatistics.hidden = tests.length === 0
// _paq.push(['trackEvent', 'solidityUnitTesting', 'runTests']) // _paq.push(['trackEvent', 'solidityUnitTesting', 'runTests'])
// async.eachOfSeries(tests, (value, key, callback) => { async.eachOfSeries(tests, (value: any, key: any, callback: any) => {
// if (this.hasBeenStopped) return if (hasBeenStopped) return
// this.runTest(value, callback) // runTest(value, callback)
// }) })
} }
const updateRunAction = (currentFile : any = null) => { const updateRunAction = (currentFile : any = null) => {

Loading…
Cancel
Save