diff --git a/commander/test/bootstrapping/commands/generator/export.spec.ts b/commander/test/bootstrapping/commands/generator/export.spec.ts index c5ad252dca..322c71a020 100644 --- a/commander/test/bootstrapping/commands/generator/export.spec.ts +++ b/commander/test/bootstrapping/commands/generator/export.spec.ts @@ -21,7 +21,6 @@ import * as appUtils from '../../../../src/utils/application'; import { ExportCommand } from '../../../../src/bootstrapping/commands/generator/export'; import { getConfig } from '../../../helpers/config'; import { Awaited } from '../../../types'; -import { OWNER_READ_WRITE } from '../../../../src/constants'; import * as outputUtils from '../../../../src/utils/output'; describe('generator:export', () => { @@ -146,13 +145,21 @@ describe('generator:export', () => { keys: [{ address: allKeysPlain[0].address, plain: allKeysPlain[0].data }], generatorInfo: info, }; + + jest + .spyOn(outputUtils, 'handleOutputFlag') + .mockImplementation(async () => + Promise.resolve('Successfully written data to /my/path/generator_info.json'), + ); + await ExportCommand.run(['--output=/my/path/info.json'], config); - expect(fs.writeJSONSync).toHaveBeenCalledTimes(1); - expect(fs.writeJSONSync).toHaveBeenCalledWith('/my/path/info.json', fileData, { - spaces: ' ', - mode: OWNER_READ_WRITE, - }); + expect(outputUtils.handleOutputFlag).toHaveBeenCalledTimes(1); + expect(outputUtils.handleOutputFlag).toHaveBeenCalledWith( + '/my/path/info.json', + fileData, + 'generator_info', + ); }); }); @@ -168,13 +175,21 @@ describe('generator:export', () => { keys: [{ address: allKeysEncrypted[0].address, encrypted: allKeysEncrypted[0].data }], generatorInfo: info, }; + + jest + .spyOn(outputUtils, 'handleOutputFlag') + .mockImplementation(async () => + Promise.resolve('Successfully written data to /my/path/generator_info.json'), + ); + await ExportCommand.run(['--output=/my/path/info.json', '--data-path=/my/app/'], config); - expect(fs.writeJSONSync).toHaveBeenCalledTimes(1); - expect(fs.writeJSONSync).toHaveBeenCalledWith('/my/path/info.json', fileData, { - spaces: ' ', - mode: OWNER_READ_WRITE, - }); + expect(outputUtils.handleOutputFlag).toHaveBeenCalledTimes(1); + expect(outputUtils.handleOutputFlag).toHaveBeenCalledWith( + '/my/path/info.json', + fileData, + 'generator_info', + ); }); }); });