@@ -25,7 +25,9 @@ import { TaskDefinitionType } from "../../../src/types/tasks.js";
25
25
*/
26
26
describe ( "TaskManagerImplementation" , ( ) => {
27
27
it ( "should initialize the task manager with an empty set of tasks if no plugins or tasks are provided" , async ( ) => {
28
- await assert . doesNotReject ( createHardhatRuntimeEnvironment ( { } ) ) ;
28
+ const hre = await createHardhatRuntimeEnvironment ( { } ) ;
29
+
30
+ assert . equal ( hre . tasks . rootTasks . size , 0 ) ;
29
31
} ) ;
30
32
31
33
it ( "should initialize the task manager with the tasks from the plugins" , async ( ) => {
@@ -79,6 +81,12 @@ describe("TaskManagerImplementation", () => {
79
81
const task3 = hre . tasks . getTask ( "task3" ) ;
80
82
assert . deepEqual ( task3 . id , [ "task3" ] ) ;
81
83
assert . equal ( task3 . pluginId , "plugin2" ) ;
84
+
85
+ // task1, task2 and task3 should be root tasks
86
+ assert . equal ( hre . tasks . rootTasks . size , 3 ) ;
87
+ assert . deepEqual ( hre . tasks . rootTasks . get ( "task1" ) ?. id , [ "task1" ] ) ;
88
+ assert . deepEqual ( hre . tasks . rootTasks . get ( "task2" ) ?. id , [ "task2" ] ) ;
89
+ assert . deepEqual ( hre . tasks . rootTasks . get ( "task3" ) ?. id , [ "task3" ] ) ;
82
90
} ) ;
83
91
84
92
it ( "should initialize the task manager with the tasks from the config" , async ( ) => {
@@ -114,6 +122,12 @@ describe("TaskManagerImplementation", () => {
114
122
const task3 = hre . tasks . getTask ( "task3" ) ;
115
123
assert . deepEqual ( task3 . id , [ "task3" ] ) ;
116
124
assert . equal ( task3 . pluginId , undefined ) ;
125
+
126
+ // task1, task2 and task3 should be root tasks
127
+ assert . equal ( hre . tasks . rootTasks . size , 3 ) ;
128
+ assert . deepEqual ( hre . tasks . rootTasks . get ( "task1" ) ?. id , [ "task1" ] ) ;
129
+ assert . deepEqual ( hre . tasks . rootTasks . get ( "task2" ) ?. id , [ "task2" ] ) ;
130
+ assert . deepEqual ( hre . tasks . rootTasks . get ( "task3" ) ?. id , [ "task3" ] ) ;
117
131
} ) ;
118
132
119
133
it ( "should override a task within the same plugin" , async ( ) => {
@@ -350,6 +364,12 @@ describe("TaskManagerImplementation", () => {
350
364
const subsubtask1 = hre . tasks . getTask ( [ "task1" , "subtask1" , "subsubtask1" ] ) ;
351
365
assert . deepEqual ( subsubtask1 . id , [ "task1" , "subtask1" , "subsubtask1" ] ) ;
352
366
assert . equal ( subsubtask1 . pluginId , "plugin2" ) ;
367
+
368
+ // task1 should be a root task, but subtask1 and subsubtask1 should not
369
+ assert . equal ( hre . tasks . rootTasks . size , 1 ) ;
370
+ assert . deepEqual ( hre . tasks . rootTasks . get ( "task1" ) ?. id , [ "task1" ] ) ;
371
+ assert . equal ( hre . tasks . rootTasks . get ( "subtask1" ) , undefined ) ;
372
+ assert . equal ( hre . tasks . rootTasks . get ( "subsubtask1" ) , undefined ) ;
353
373
} ) ;
354
374
355
375
/**
0 commit comments