From 9c292fbd5f6cf7f5e091bf9f6f210a488aa9b0f1 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 18 Nov 2021 11:45:58 +0530 Subject: [PATCH] listTests --- .../src/lib/solidity-unit-testing.tsx | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx index 3c10fc2927..e638ebf804 100644 --- a/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx +++ b/libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx @@ -21,6 +21,8 @@ export const SolidityUnitTesting = (props: any) => { const [testsExecutionStoppedErrorHidden, setTestsExecutionStoppedErrorHidden] = useState(true) const [testsMessage, setTestsMessage] = useState('No test file available') const [pathOptions, setPathOptions] = useState(['']) + const [allTests, setAllTests] = useState([]) + const [selectedTests, setSelectedTests] = useState([]) const [inputPathValue, setInputPathValue] = useState('tests') @@ -41,22 +43,21 @@ export const SolidityUnitTesting = (props: any) => { // // if current file is changed while debugging and one of the files imported in test file are opened // // do not clear the test results in SUT plugin // if (this.isDebugging && this.allFilesInvolved.includes(file)) return - // this.data.allTests = [] - // this.updateTestFileList() + console.log('Inside updateForNewCurrent --allTests-->', allTests) + updateTestFileList() // this.clearResults() - // this.updateGenerateFileAction() // if (!this.areTestsRunning) this.updateRunAction(file) - // try { - // await this.testTabLogic.getTests((error, tests) => { - // if (error) return tooltip(error) - // this.data.allTests = tests - // this.data.selectedTests = [...this.data.allTests] - // this.updateTestFileList(tests) - // if (!this.testsOutput) return // eslint-disable-line - // }) - // } catch (e) { - // console.log(e) - // } + try { + await testTabLogic.getTests((error: any, tests: any) => { + // if (error) return tooltip(error) + setAllTests(tests) + setSelectedTests(tests) + updateTestFileList(tests) + // if (!this.testsOutput) return // eslint-disable-line + }) + } catch (e) { + console.log('error in updateForNewCurrent', e) + } } useEffect(() => { @@ -225,12 +226,21 @@ export const SolidityUnitTesting = (props: any) => { // } } + const createSingleTest = (testFile) => { + return yo` +
+ this.toggleCheckbox(e.target.checked, testFile)} type="checkbox" checked="true"> + +
+ ` + } + const listTests = () => { - console.log('listTests--->') - // if (!this.data.allTests || !this.data.allTests.length) return [] - // return this.data.allTests.map( - // testFile => this.createSingleTest(testFile) - // ) + console.log('listTests--->', allTests) + if (!allTests || !allTests.length) return [] + return allTests.map( + testFile => createSingleTest(testFile) + ) } const updateTestFileList = (tests = []) => {