@@ -39,9 +39,9 @@ jest.mock('../../../if-run/builtins/export-yaml', () => ({
39
39
if ( process . env . CONTEXT !== 'default-name-description' ) {
40
40
expectedContext . name = 'mock name' ;
41
41
expectedContext . description = 'mock description' ;
42
- expect ( outputPath ) . toBe ( 'mock-dir/mock-name.yaml ' ) ;
42
+ expect ( outputPath ) . toBe ( 'mock-outputPath ' ) ;
43
43
} else {
44
- expect ( outputPath ) . toBe ( 'mock-dir/merged-manifest.yaml ' ) ;
44
+ expect ( outputPath ) . toBe ( 'mock-outputPath ' ) ;
45
45
}
46
46
47
47
expect ( context ) . toEqual ( expectedContext ) ;
@@ -50,9 +50,16 @@ jest.mock('../../../if-run/builtins/export-yaml', () => ({
50
50
} ) ) ;
51
51
52
52
describe ( 'if-merge/util/helpers: ' , ( ) => {
53
+ const consopleSpy = jest . spyOn ( global . console , 'log' ) ;
54
+
55
+ beforeEach ( ( ) => {
56
+ consopleSpy . mockReset ( ) ;
57
+ } ) ;
58
+
53
59
describe ( 'mergeManifests(): ' , ( ) => {
54
60
const mockCommandArgs = {
55
61
manifests : [ 'manifest1.yaml' , 'manifest2.yaml' ] ,
62
+ output : 'mock-outputPath' ,
56
63
name : 'mock name' ,
57
64
description : 'mock description' ,
58
65
} ;
@@ -128,9 +135,27 @@ describe('if-merge/util/helpers: ', () => {
128
135
expect ( load ) . toHaveBeenCalledTimes ( 2 ) ;
129
136
} ) ;
130
137
138
+ it ( 'successfully prints merged manifests when the `output` is not provided.' , async ( ) => {
139
+ ( getFileName as jest . Mock ) . mockImplementation ( file =>
140
+ file . replace ( '.yaml' , '' )
141
+ ) ;
142
+ ( load as jest . Mock ) . mockResolvedValue ( { rawManifest : mockRawManifest } ) ;
143
+
144
+ const mockCommandArgs = {
145
+ manifests : [ 'manifest1.yaml' , 'manifest2.yaml' ] ,
146
+ name : 'mock name' ,
147
+ description : 'mock description' ,
148
+ } ;
149
+ await mergeManifests ( mockCommandArgs ) ;
150
+
151
+ expect . assertions ( 1 ) ;
152
+ expect ( consopleSpy ) . toHaveBeenCalledTimes ( 1 ) ;
153
+ } ) ;
154
+
131
155
it ( 'gets YAML files when there is only one manifest.' , async ( ) => {
132
156
const singleManifestArgs = {
133
157
manifests : [ 'mock-dir' ] ,
158
+ output : 'mock-outputPath' ,
134
159
name : 'mock name' ,
135
160
description : 'mock description' ,
136
161
} ;
@@ -153,7 +178,10 @@ describe('if-merge/util/helpers: ', () => {
153
178
it ( 'uses default values for name and description if not provided.' , async ( ) => {
154
179
process . env . CONTEXT = 'default-name-description' ;
155
180
156
- const defaultArgs = { manifests : [ 'manifest1.yaml' , 'manifest2.yaml' ] } ;
181
+ const defaultArgs = {
182
+ manifests : [ 'manifest1.yaml' , 'manifest2.yaml' ] ,
183
+ output : 'mock-outputPath' ,
184
+ } ;
157
185
158
186
( getFileName as jest . Mock ) . mockImplementation ( file =>
159
187
file . replace ( '.yaml' , '' )
0 commit comments