@@ -2,6 +2,7 @@ import { GenerateArazzoCommandArgv, handleGenerateArazzo } from '../../commands/
22import { generate } from '@redocly/respect-core' ;
33import { vi , describe , it , expect , beforeEach } from 'vitest' ;
44import * as openapiCore from '@redocly/openapi-core' ;
5+ import { writeFileSync } from 'node:fs' ;
56
67vi . mock ( '@redocly/respect-core' , async ( ) => {
78 const actual = await vi . importActual < typeof import ( '@redocly/respect-core' ) > (
@@ -24,6 +25,11 @@ vi.mock('@redocly/openapi-core', async () => {
2425 } ;
2526} ) ;
2627
28+ vi . mock ( 'node:fs' , ( ) => ( {
29+ writeFileSync : vi . fn ( ) ,
30+ existsSync : vi . fn ( ( ) => false ) ,
31+ } ) ) ;
32+
2733describe ( 'handleGenerateArazzo' , ( ) => {
2834 beforeEach ( ( ) => {
2935 vi . clearAllMocks ( ) ;
@@ -50,6 +56,7 @@ describe('handleGenerateArazzo', () => {
5056 version : '1.0.0' ,
5157 config : mockConfig ,
5258 } ) ;
59+ expect ( writeFileSync ) . toHaveBeenCalledWith ( 'auto-generated.arazzo.yaml' , 'mocked yaml' ) ;
5360 } ) ;
5461
5562 it ( 'should use custom output file when provided' , async ( ) => {
@@ -73,6 +80,8 @@ describe('handleGenerateArazzo', () => {
7380 version : '1.0.0' ,
7481 config : mockConfig ,
7582 } ) ;
83+
84+ expect ( writeFileSync ) . toHaveBeenCalledWith ( 'custom.arazzo.yaml' , 'mocked yaml' ) ;
7685 } ) ;
7786
7887 it ( 'should throw an error if the openapi file is not valid' , async ( ) => {
@@ -91,5 +100,6 @@ describe('handleGenerateArazzo', () => {
91100 await expect ( handleGenerateArazzo ( commandArgs ) ) . rejects . toThrow (
92101 '❌ Failed to generate Arazzo description. Check the output file path you provided, or the OpenAPI file content.'
93102 ) ;
103+ expect ( writeFileSync ) . not . toHaveBeenCalled ( ) ;
94104 } ) ;
95105} ) ;
0 commit comments