toaster for testTabLogic error

pull/1862/head
aniket-engg 3 years ago committed by Aniket
parent b1d794f2c0
commit 4644886240
  1. 8
      libs/remix-ui/solidity-unit-testing/src/lib/logic/testTabLogic.ts
  2. 2
      libs/remix-ui/solidity-unit-testing/src/lib/solidity-unit-testing.tsx

@ -35,8 +35,7 @@ export class TestTabLogic {
return res
}
generateTestFile () {
console.log('Inside generateTestFile-1SUT-currentFile-', this.fileManager.currentFile(), this.currentPath)
generateTestFile (errorCb: any) {
let fileName = this.fileManager.currentFile()
const hasCurrent = !!fileName && this.fileManager.currentFile().split('.').pop().toLowerCase() === 'sol'
if (!hasCurrent) fileName = this.currentPath + '/newFile.sol'
@ -45,10 +44,9 @@ export class TestTabLogic {
const splittedFileName = fileName.split('/')
const fileNameToImport = (!hasCurrent) ? fileName : this.currentPath + '/' + splittedFileName[splittedFileName.length - 1]
this.helper.createNonClashingNameWithPrefix(fileNameToImport, fileProvider, '_test', (error: any, newFile: any) => {
// if (error) return modalDialogCustom.alert('Failed to create file. ' + newFile + ' ' + error)
if (error) return errorCb('Failed to create file. ' + newFile + ' ' + error)
const isFileCreated = fileProvider.set(newFile, this.generateTestContractSample(hasCurrent, fileName))
console.log('isFileCreated--->', isFileCreated)
// if (!isFileCreated) return modalDialogCustom.alert('Failed to create test file ' + newFile)
if (!isFileCreated) return errorCb('Failed to create test file ' + newFile)
this.fileManager.open(newFile)
this.fileManager.syncEditor(newFile)
})

@ -676,7 +676,7 @@ export const SolidityUnitTesting = (props: Record<string, any>) => {
title="Generate sample test file."
disabled={disableGenerateButton}
onClick={() => {
testTabLogic.generateTestFile()
testTabLogic.generateTestFile((err:any) => { if (err) setToasterMsg(err)})
updateForNewCurrent()
}}
>

Loading…
Cancel
Save