renderContract

pull/5370/head
aniket-engg 3 years ago committed by Aniket
parent a1d096f0d5
commit 5402ea94e7
  1. 44
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx

@ -232,21 +232,25 @@ export const SolidityUnitTesting = (props: any) => {
} }
} }
const renderTests = (tests: any, contract: any, filename: any) => { const renderContract = (filename: any, contract: any, index: number, withoutLabel = false) => {
const index = tests.findIndex((test: any) => test.type === 'testFailure') if (withoutLabel) {
let label = (<div const contractCard: any = (
className="alert-primary d-inline-block mb-1 mr-1 p-1 failed_${this.runningTestFileName}" <div id={runningTestFileName} data-id="testTabSolidityUnitTestsOutputheader" className="pt-1">
> <span className="font-weight-bold">{contract ? contract: ''} ({filename})</span>
Unknown </div>
</div>) )
setTestsOutput(prevCards => ([...prevCards, contractCard]))
return
}
let label
if (index > -1) label = (<div if (index > -1) label = (<div
className="alert-danger d-inline-block mb-1 mr-1 p-1 failed_${this.runningTestFileName}" className="alert-danger d-inline-block mb-1 mr-1 p-1 failed_{runningTestFileName}"
title="At least one contract test failed" title="At least one contract test failed"
> >
FAIL FAIL
</div>) </div>)
else label = (<div else label = (<div
className="alert-success d-inline-block mb-1 mr-1 p-1 passed_${this.runningTestFileName}" className="alert-success d-inline-block mb-1 mr-1 p-1 passed_{runningTestFileName}"
title="All contract tests passed" title="All contract tests passed"
> >
PASS PASS
@ -262,6 +266,12 @@ export const SolidityUnitTesting = (props: any) => {
prevCards[index] = ContractCard prevCards[index] = ContractCard
return prevCards return prevCards
}) })
}
const renderTests = (tests: any, contract: any, filename: any) => {
const index = tests.findIndex((test: any) => test.type === 'testFailure')
// show filename and contract
renderContract(filename, contract, index)
// show tests // show tests
for(const test of tests) { for(const test of tests) {
if(!test.rendered) { if(!test.rendered) {
@ -357,12 +367,7 @@ export const SolidityUnitTesting = (props: any) => {
renderTests(tests, contract, filename) renderTests(tests, contract, filename)
} else { } else {
// show only contract and file name // show only contract and file name
const contractCard: any = ( renderContract(filename, contract, -1, true)
<div id={runningTestFileName} data-id="testTabSolidityUnitTestsOutputheader" className="pt-1">
<span className="font-weight-bold">{contract ? contract: ''} ({filename})</span>
</div>
)
setTestsOutput(prevCards => ([...prevCards, contractCard]))
} }
} else if (contract === 'errors' && fileTestsResult['errors']) { } else if (contract === 'errors' && fileTestsResult['errors']) {
const errors = fileTestsResult['errors'] const errors = fileTestsResult['errors']
@ -433,13 +438,8 @@ export const SolidityUnitTesting = (props: any) => {
++readyTestsNumber ++readyTestsNumber
setReadyTestsNumber(readyTestsNumber) setReadyTestsNumber(readyTestsNumber)
if (!result && (_errors && (_errors.errors || (Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage))))) { if (!result && (_errors && (_errors.errors || (Array.isArray(_errors) && (_errors[0].message || _errors[0].formattedMessage))))) {
// testCallback({ type: 'contract', filename }) // show only file name
const contractCard: any = ( renderContract(filename, null, -1, true)
<div id={runningTestFileName} data-id="testTabSolidityUnitTestsOutputheader" className="pt-1">
<span className="font-weight-bold">({filename})</span>
</div>
)
setTestsOutput(prevCards => ([...prevCards, contractCard]))
currentErrors = _errors.errors currentErrors = _errors.errors
// this.setHeader(false) // this.setHeader(false)
} }

Loading…
Cancel
Save