( struct: ProcessedStruct, functions: CodeGenFunction[], libraryName: string )
| 206 | } |
| 207 | |
| 208 | export function generateHardhatTest( |
| 209 | struct: ProcessedStruct, |
| 210 | functions: CodeGenFunction[], |
| 211 | libraryName: string |
| 212 | ) { |
| 213 | const fnTests: ArrayJoinInput<string>[] = []; |
| 214 | for (const fn of functions) { |
| 215 | const code = generateHardhatTestForFunction(struct, fn, libraryName) |
| 216 | if (code) fnTests.push(...code, ''); |
| 217 | } |
| 218 | removeTrailingNewLines(fnTests) |
| 219 | // const fnTests = functions.map(fn => generateHardhatTestForFunction(fn, libraryName)).filter(Boolean); |
| 220 | const contractName = `external${libraryName}`; |
| 221 | const testFile = [ |
| 222 | `import { ethers } from 'hardhat';`, |
| 223 | `import { expect } from "chai";`, |
| 224 | '', |
| 225 | `describe('${libraryName}Coder.sol', () => {`, |
| 226 | [ |
| 227 | `let ${contractName}: any;`, |
| 228 | '', |
| 229 | `before(async () => {`, |
| 230 | [ |
| 231 | `const Factory = await ethers.getContractFactory('External${libraryName}Coder');`, |
| 232 | `${contractName} = await Factory.deploy();` |
| 233 | ], |
| 234 | '})', |
| 235 | '', |
| 236 | ...fnTests |
| 237 | ], |
| 238 | '})' |
| 239 | ]; |
| 240 | return arrJoiner(testFile); |
| 241 | } |
no test coverage detected