|
1 |
| -import { existsSync } from 'fs'; |
| 1 | +import { existsSync, readFileSync, writeFileSync } from 'fs'; |
2 | 2 | import { join } from 'path';
|
3 | 3 |
|
4 | 4 | import * as deployMod from '../../src/cli/commands/deploy/index';
|
@@ -74,7 +74,7 @@ describe(
|
74 | 74 |
|
75 | 75 | await runInit({
|
76 | 76 | root: paths.root,
|
77 |
| - workspace: paths.workspaceDir, |
| 77 | + contracts: paths.contractsDir, |
78 | 78 | output: paths.outputDir,
|
79 | 79 | });
|
80 | 80 |
|
@@ -110,6 +110,44 @@ describe(
|
110 | 110 | expect(deploy).toHaveBeenCalledTimes(1);
|
111 | 111 | expect(killChildProcess).toHaveBeenCalledTimes(1);
|
112 | 112 | });
|
| 113 | + |
| 114 | + it("should run `build` with `forcBuildFlags: ['--release']`", async () => { |
| 115 | + const { autoStartFuelCore, killChildProcess, deploy } = mockAll(); |
| 116 | + |
| 117 | + await runInit({ |
| 118 | + root: paths.root, |
| 119 | + workspace: paths.workspaceDir, |
| 120 | + output: paths.outputDir, |
| 121 | + }); |
| 122 | + |
| 123 | + // inject `forcBuildFlags: ['--release']` in config file |
| 124 | + const configFilepath = join(paths.root, 'fuels.config.ts'); |
| 125 | + const configContents = readFileSync(configFilepath, 'utf-8'); |
| 126 | + |
| 127 | + const search = " output: './output',"; |
| 128 | + const replace = [search, " forcBuildFlags: ['--release'],"].join('\n'); |
| 129 | + const configContentsNew = configContents.replace(search, replace); |
| 130 | + |
| 131 | + writeFileSync(configFilepath, configContentsNew); |
| 132 | + |
| 133 | + // moving on |
| 134 | + await runBuild({ root: paths.root }); |
| 135 | + |
| 136 | + const files = [ |
| 137 | + 'contracts/FooBarAbi.hex.ts', |
| 138 | + 'contracts/FooBarAbi.d.ts', |
| 139 | + 'contracts/factories/FooBarAbi__factory.ts', |
| 140 | + 'contracts/index.ts', |
| 141 | + 'index.ts', |
| 142 | + ].map((f) => join(paths.outputDir, f)); |
| 143 | + |
| 144 | + files.forEach((file) => expect(existsSync(file)).toBeTruthy()); |
| 145 | + |
| 146 | + expect(autoStartFuelCore).toHaveBeenCalledTimes(0); |
| 147 | + expect(deploy).toHaveBeenCalledTimes(0); |
| 148 | + expect(killChildProcess).toHaveBeenCalledTimes(0); |
| 149 | + }); |
113 | 150 | },
|
| 151 | + |
114 | 152 | { timeout: 180000 }
|
115 | 153 | );
|
0 commit comments