) => {
// show filename and contract
renderContract(filename, contract, index)
// show tests
- for(const test of tests) {
- if(!test.rendered) {
+ for (const test of tests) {
+ if (!test.rendered) {
let debugBtn
if (test.debugTxHash) {
const { web3, debugTxHash } = test
debugBtn = (
-
startDebug(debugTxHash, web3)}>
-
-
+
startDebug(debugTxHash, web3)}>
+
+
)
- }
+ }
if (test.type === 'testPass') {
if (test.hhLogs && test.hhLogs.length) printHHLogs(test.hhLogs, test.value)
const testPassCard: any = (
@@ -325,71 +329,71 @@ export const SolidityUnitTesting = (props: Record
) => {
>
✓ {test.value}
- {debugBtn}
-
+ {debugBtn}
+
)
setTestsOutput(prevCards => ([...prevCards, testPassCard]))
test.rendered = true
} else if (test.type === 'testFailure') {
- if (test.hhLogs && test.hhLogs.length) printHHLogs(test.hhLogs, test.value)
- if (!test.assertMethod) {
- const testFailCard1: any = ( highlightLocation(test.location, test.filename)}
- >
-
- ✘ {test.value}
- {debugBtn}
-
-
Error Message:
-
"{test.errMsg}"
-
)
- setTestsOutput(prevCards => ([...prevCards, testFailCard1]))
- } else {
- const preposition = test.assertMethod === 'equal' || test.assertMethod === 'notEqual' ? 'to' : ''
- const method = test.assertMethod === 'ok' ? '' : test.assertMethod
- const expected = test.assertMethod === 'ok' ? '\'true\'' : test.expected
- const testFailCard2: any = ( highlightLocation(test.location, test.filename)}
- >
-
- ✘ {test.value}
- {debugBtn}
-
-
Error Message:
-
"{test.errMsg}"
-
Assertion:
-
-
Expected value should be
-
{method}
-
{preposition} {expected}
-
-
Received value:
-
{test.returned}
-
Skipping the remaining tests of the function.
-
)
- setTestsOutput(prevCards => ([...prevCards, testFailCard2]))
- }
- test.rendered = true
- } else if (test.type === 'logOnly') {
- if (test.hhLogs && test.hhLogs.length) printHHLogs(test.hhLogs, test.value)
- test.rendered = true
- }
+ if (test.hhLogs && test.hhLogs.length) printHHLogs(test.hhLogs, test.value)
+ if (!test.assertMethod) {
+ const testFailCard1: any = ( highlightLocation(test.location, test.filename)}
+ >
+
+ ✘ {test.value}
+ {debugBtn}
+
+
Error Message:
+
"{test.errMsg}"
+
)
+ setTestsOutput(prevCards => ([...prevCards, testFailCard1]))
+ } else {
+ const preposition = test.assertMethod === 'equal' || test.assertMethod === 'notEqual' ? 'to' : ''
+ const method = test.assertMethod === 'ok' ? '' : test.assertMethod
+ const expected = test.assertMethod === 'ok' ? '\'true\'' : test.expected
+ const testFailCard2: any = ( highlightLocation(test.location, test.filename)}
+ >
+
+ ✘ {test.value}
+ {debugBtn}
+
+
Error Message:
+
"{test.errMsg}"
+
Assertion:
+
+
Expected value should be
+
{method}
+
{preposition} {expected}
+
+
Received value:
+
{test.returned}
+
Skipping the remaining tests of the function.
+
)
+ setTestsOutput(prevCards => ([...prevCards, testFailCard2]))
+ }
+ test.rendered = true
+ } else if (test.type === 'logOnly') {
+ if (test.hhLogs && test.hhLogs.length) printHHLogs(test.hhLogs, test.value)
+ test.rendered = true
+ }
}
}
}
const showTestsResult = () => {
const filenames = Object.keys(testsResultByFilename)
- for(const filename of filenames) {
+ for (const filename of filenames) {
const fileTestsResult = testsResultByFilename[filename]
const contracts = Object.keys(fileTestsResult)
- for(const contract of contracts) {
- if(contract && contract !== 'summary' && contract !== 'errors') {
+ for (const contract of contracts) {
+ if (contract && contract !== 'summary' && contract !== 'errors') {
runningTestFileName = cleanFileName(filename, contract)
const tests = fileTestsResult[contract]
if (tests?.length) {
@@ -402,19 +406,19 @@ export const SolidityUnitTesting = (props: Record