@@ -3,12 +3,22 @@ import { buildMockProject } from '../tests/unit/helpers.js';
3
3
import { main } from './main.js' ;
4
4
import * as initialParametersModule from './initial-parameters.js' ;
5
5
import * as monorepoWorkflowOperations from './monorepo-workflow-operations.js' ;
6
+ import * as ui from './ui.js' ;
6
7
7
8
jest . mock ( './initial-parameters' ) ;
8
9
jest . mock ( './monorepo-workflow-operations' ) ;
10
+ jest . mock ( './ui' ) ;
11
+ jest . mock ( './dirname' , ( ) => ( {
12
+ getCurrentDirectoryPath : jest . fn ( ) . mockReturnValue ( '/path/to/somewhere' ) ,
13
+ } ) ) ;
14
+ jest . mock ( 'open' , ( ) => ( {
15
+ apps : {
16
+ browser : jest . fn ( ) ,
17
+ } ,
18
+ } ) ) ;
9
19
10
20
describe ( 'main' , ( ) => {
11
- it ( 'executes the monorepo workflow if the project is a monorepo' , async ( ) => {
21
+ it ( 'executes the CLI monorepo workflow if the project is a monorepo and interactive is false ' , async ( ) => {
12
22
const project = buildMockProject ( { isMonorepo : true } ) ;
13
23
const stdout = fs . createWriteStream ( '/dev/null' ) ;
14
24
const stderr = fs . createWriteStream ( '/dev/null' ) ;
@@ -20,6 +30,8 @@ describe('main', () => {
20
30
reset : true ,
21
31
defaultBranch : 'main' ,
22
32
releaseType : 'backport' ,
33
+ interactive : false ,
34
+ port : 3000 ,
23
35
} ) ;
24
36
const followMonorepoWorkflowSpy = jest
25
37
. spyOn ( monorepoWorkflowOperations , 'followMonorepoWorkflow' )
@@ -43,6 +55,40 @@ describe('main', () => {
43
55
} ) ;
44
56
} ) ;
45
57
58
+ it ( 'executes the interactive UI monorepo workflow if the project is a monorepo and interactive is true' , async ( ) => {
59
+ const project = buildMockProject ( { isMonorepo : true } ) ;
60
+ const stdout = fs . createWriteStream ( '/dev/null' ) ;
61
+ const stderr = fs . createWriteStream ( '/dev/null' ) ;
62
+ jest
63
+ . spyOn ( initialParametersModule , 'determineInitialParameters' )
64
+ . mockResolvedValue ( {
65
+ project,
66
+ tempDirectoryPath : '/path/to/temp/directory' ,
67
+ reset : true ,
68
+ defaultBranch : 'main' ,
69
+ releaseType : 'backport' ,
70
+ interactive : true ,
71
+ port : 3000 ,
72
+ } ) ;
73
+ const startUISpy = jest . spyOn ( ui , 'startUI' ) . mockResolvedValue ( ) ;
74
+
75
+ await main ( {
76
+ argv : [ ] ,
77
+ cwd : '/path/to/somewhere' ,
78
+ stdout,
79
+ stderr,
80
+ } ) ;
81
+
82
+ expect ( startUISpy ) . toHaveBeenCalledWith ( {
83
+ project,
84
+ releaseType : 'backport' ,
85
+ defaultBranch : 'main' ,
86
+ port : 3000 ,
87
+ stdout,
88
+ stderr,
89
+ } ) ;
90
+ } ) ;
91
+
46
92
it ( 'executes the polyrepo workflow if the project is within a polyrepo' , async ( ) => {
47
93
const project = buildMockProject ( { isMonorepo : false } ) ;
48
94
const stdout = fs . createWriteStream ( '/dev/null' ) ;
@@ -55,6 +101,8 @@ describe('main', () => {
55
101
reset : false ,
56
102
defaultBranch : 'main' ,
57
103
releaseType : 'backport' ,
104
+ interactive : false ,
105
+ port : 3000 ,
58
106
} ) ;
59
107
const followMonorepoWorkflowSpy = jest
60
108
. spyOn ( monorepoWorkflowOperations , 'followMonorepoWorkflow' )
0 commit comments