Skip to content

Commit 4ebe42e

Browse files
committed
update existing tests
1 parent d38777a commit 4ebe42e

File tree

6 files changed

+57
-54
lines changed

6 files changed

+57
-54
lines changed

v-next/core/test/internal/hook-manager.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ describe("HookManager", () => {
9090
plugins: [],
9191
},
9292
hooks: hookManager,
93-
globalArguments: {},
93+
globalOptions: {},
9494
interruptions: userInterruptionsManager,
9595
});
9696

@@ -295,7 +295,7 @@ describe("HookManager", () => {
295295
plugins: [],
296296
},
297297
hooks: hookManager,
298-
globalArguments: {},
298+
globalOptions: {},
299299
interruptions: userInterruptionsManager,
300300
});
301301

@@ -509,7 +509,7 @@ describe("HookManager", () => {
509509
plugins: [],
510510
},
511511
hooks: hookManager,
512-
globalArguments: {},
512+
globalOptions: {},
513513
interruptions: userInterruptionsManager,
514514
});
515515

@@ -634,7 +634,7 @@ describe("HookManager", () => {
634634
plugins: [],
635635
},
636636
hooks: hookManager,
637-
globalArguments: {},
637+
globalOptions: {},
638638
interruptions: userInterruptionsManager,
639639
});
640640

@@ -778,7 +778,7 @@ describe("HookManager", () => {
778778
plugins: [],
779779
},
780780
hooks: hookManager,
781-
globalArguments: {},
781+
globalOptions: {},
782782
interruptions: userInterruptionsManager,
783783
});
784784

@@ -935,7 +935,7 @@ function buildMockHardhatRuntimeEnvironment(
935935
plugins: [],
936936
},
937937
tasks: mockTaskManager,
938-
globalArguments: {},
938+
globalOptions: {},
939939
interruptions: mockInteruptionManager,
940940
};
941941

v-next/hardhat/src/internal/cli/helpers/getGlobalHelpString.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Task } from "@nomicfoundation/hardhat-core/types/tasks";
22

3-
import { getVersionString } from "./getVersionString.js";
3+
import { getHardhatVersion } from "../../utils/package.js";
4+
45
import {
56
GLOBAL_NAME_PADDING,
67
GLOBAL_OPTIONS,
@@ -12,7 +13,7 @@ import {
1213
export async function getGlobalHelpString(
1314
rootTasks: Map<string, Task>,
1415
): Promise<string> {
15-
const version = await getVersionString();
16+
const version = await getHardhatVersion();
1617

1718
const { tasks, subtasks } = parseTasks(rootTasks);
1819

v-next/hardhat/src/internal/cli/helpers/getVersionString.ts

-7
This file was deleted.

v-next/hardhat/test/fixture-projects/cli/parsing/base-project/hardhat.config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const tasksResults = {
77
};
88

99
const customTask = task("task")
10+
.setDescription("A task that uses param1")
1011
.setAction(() => {
1112
tasksResults.wasParam1Used = true;
1213
})

v-next/hardhat/test/internal/cli/helpers/getVersionString.ts

-13
This file was deleted.

v-next/hardhat/test/internal/cli/main.ts

+47-26
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from "@nomicfoundation/hardhat-core/config";
2222
import { HardhatError } from "@nomicfoundation/hardhat-errors";
2323
import { isCi } from "@nomicfoundation/hardhat-utils/ci";
24+
import chalk from "chalk";
2425

2526
import {
2627
main,
@@ -207,63 +208,83 @@ describe("main", function () {
207208
});
208209
});
209210

210-
// TODO: as soon as the 'help task' is done, this test should be updated
211211
describe("global help", function () {
212212
useFixtureProject("cli/parsing/base-project");
213213

214-
it.todo("should print the global help", async function () {
215-
const lines: string[] = [];
214+
it("should print the global help", async function () {
215+
let lines: string = "";
216216

217217
const command = "npx hardhat";
218218
const cliArguments = command.split(" ").slice(2);
219219

220220
await main(cliArguments, (msg) => {
221-
lines.push(msg);
221+
lines = msg;
222222
});
223223

224-
assert.equal(lines.length, 2);
225-
assert.equal(lines[1], "Global help");
224+
const expected = `Hardhat version 3.0.0
225+
226+
Usage: hardhat [GLOBAL OPTIONS] <TASK> [SUBTASK] [TASK OPTIONS] [--] [TASK ARGUMENTS]
227+
228+
AVAILABLE TASKS:
229+
230+
example Example task
231+
task A task that uses param1
232+
233+
GLOBAL OPTIONS:
234+
235+
--config A Hardhat config file.
236+
--help Shows this message, or a task's help if its name is provided
237+
--show-stack-traces Show stack traces (always enabled on CI servers).
238+
--version Shows hardhat's version.
239+
240+
To get help for a specific task run: npx hardhat <TASK> [SUBTASK] --help`;
241+
242+
assert.equal(lines, expected);
226243
});
227244
});
228245

229-
// TODO: as soon as the 'help task' is done, this test should be updated
230246
describe("subtask help", function () {
231247
useFixtureProject("cli/parsing/subtask-help");
232248

233-
it.todo(
234-
"should print an help message for the task's subtask",
235-
async function () {
236-
const lines: string[] = [];
249+
it("should print an help message for the task's subtask", async function () {
250+
let lines: string = "";
237251

238-
const command = "npx hardhat empty-task --help";
239-
const cliArguments = command.split(" ").slice(2);
252+
const command = "npx hardhat empty-task --help";
253+
const cliArguments = command.split(" ").slice(2);
240254

241-
await main(cliArguments, (msg) => {
242-
lines.push(msg);
243-
});
255+
await main(cliArguments, (msg) => {
256+
lines = msg;
257+
});
244258

245-
assert.equal(lines.length, 2);
246-
assert.equal(lines[1], "Info about subtasks");
247-
},
248-
);
259+
const expected = `${chalk.bold("empty task description")}
260+
261+
Usage: hardhat [GLOBAL OPTIONS] empty-task <SUBTASK> [SUBTASK OPTIONS] [--] [SUBTASK POSITIONAL ARGUMENTS]
262+
`;
263+
264+
assert.equal(lines, expected);
265+
});
249266
});
250267

251-
// TODO: as soon as the 'help task' is done, this test should be updated
252268
describe("task help", function () {
253269
useFixtureProject("cli/parsing/base-project");
254270

255-
it.todo("should print an help message for the task", async function () {
256-
const lines: string[] = [];
271+
it("should print an help message for the task", async function () {
272+
let lines: string = "";
257273

258274
const command = "npx hardhat task --help";
259275
const cliArguments = command.split(" ").slice(2);
260276

261277
await main(cliArguments, (msg) => {
262-
lines.push(msg);
278+
lines = msg;
263279
});
264280

265-
assert.equal(lines.length, 2);
266-
assert.equal(lines[1], "Help message of the task");
281+
const expected = `${chalk.bold("A task that uses param1")}
282+
283+
Usage: hardhat [GLOBAL OPTIONS] task
284+
285+
For global options help run: hardhat --help`;
286+
287+
assert.equal(lines, expected);
267288
});
268289
});
269290
});

0 commit comments

Comments
 (0)