@@ -176,4 +176,54 @@ describe('split', () => {
176176
177177 expect ( utils . escapeLanguageName ) . toBeCalledTimes ( 3 ) ;
178178 } ) ;
179+
180+ it ( 'should split an AsyncAPI 2 file and show the success message' , async ( ) => {
181+ const filePath = 'packages/cli/src/commands/split/__tests__/fixtures/asyncapi2.json' ;
182+
183+ vi . spyOn ( process . stderr , 'write' ) . mockImplementation ( ( ) => true ) ;
184+
185+ await handleSplit ( {
186+ argv : {
187+ api : filePath ,
188+ outDir : openapiDir ,
189+ separator : '_' ,
190+ } ,
191+ config : configFixture ,
192+ version : 'cli-version' ,
193+ } ) ;
194+
195+ expect ( vi . mocked ( process . stderr . write ) ) . toBeCalledTimes ( 2 ) ;
196+ expect ( vi . mocked ( process . stderr . write ) . mock . calls [ 0 ] [ 0 ] ) . toBe (
197+ `🪓 Document: ${ blue ( filePath ! ) } ${ green ( 'is successfully split' ) }
198+ and all related files are saved to the directory: ${ blue ( openapiDir ) } \n`
199+ ) ;
200+ expect ( vi . mocked ( process . stderr . write ) . mock . calls [ 1 ] [ 0 ] ) . toContain (
201+ `${ filePath } : split processed in <test>ms`
202+ ) ;
203+ } ) ;
204+
205+ it ( 'should split an AsyncAPI 3 file and show the success message' , async ( ) => {
206+ const filePath = 'packages/cli/src/commands/split/__tests__/fixtures/asyncapi3.json' ;
207+
208+ vi . spyOn ( process . stderr , 'write' ) . mockImplementation ( ( ) => true ) ;
209+
210+ await handleSplit ( {
211+ argv : {
212+ api : filePath ,
213+ outDir : openapiDir ,
214+ separator : '_' ,
215+ } ,
216+ config : configFixture ,
217+ version : 'cli-version' ,
218+ } ) ;
219+
220+ expect ( vi . mocked ( process . stderr . write ) ) . toBeCalledTimes ( 2 ) ;
221+ expect ( vi . mocked ( process . stderr . write ) . mock . calls [ 0 ] [ 0 ] ) . toBe (
222+ `🪓 Document: ${ blue ( filePath ! ) } ${ green ( 'is successfully split' ) }
223+ and all related files are saved to the directory: ${ blue ( openapiDir ) } \n`
224+ ) ;
225+ expect ( vi . mocked ( process . stderr . write ) . mock . calls [ 1 ] [ 0 ] ) . toContain (
226+ `${ filePath } : split processed in <test>ms`
227+ ) ;
228+ } ) ;
179229} ) ;
0 commit comments