From 360419c970194a04c3e1ac12f9b16da481df7ecc Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 2 Dec 2021 20:04:22 +0530 Subject: [PATCH] highlightLocation --- .../src/lib/solidity-unit-testing.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 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 87f67fdcf7..77a9cd1ee1 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 @@ -214,6 +214,24 @@ export const SolidityUnitTesting = (props: any) => { testTab.call('terminal', 'log', { type: 'info', value: finalLogs }) } + const highlightLocation = async (location: any, runningTests: any, fileName: any) => { + if (location) { + var split = location.split(':') + var file = split[2] + location = { + start: parseInt(split[0]), + length: parseInt(split[1]) + } + location = testTab.offsetToLineColumnConverter.offsetToLineColumnWithContent( + location, + parseInt(file), + runningTests[fileName].content + ) + await testTab.call('editor', 'discardHighlight') + await testTab.call('editor', 'highlight', location, fileName, '', { focus: true }) + } + } + const testCallback = (result: any, runningTests: any) => { console.log('result---in testCallback->', result) let debugBtn @@ -261,7 +279,7 @@ export const SolidityUnitTesting = (props: any) => { const testFailCard1: any = (
this.highlightLocation(result.location, runningTests, result.filename)} + onClick={() => highlightLocation(result.location, runningTests, result.filename)} >
✘ {result.value} @@ -278,7 +296,7 @@ export const SolidityUnitTesting = (props: any) => { const testFailCard2: any = (
this.highlightLocation(result.location, runningTests, result.filename)} + onClick={() => highlightLocation(result.location, runningTests, result.filename)} >
✘ {result.value}