Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mosmartin committed Nov 30, 2023
1 parent 790e37d commit c890eb1
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions commander/test/bootstrapping/commands/generator/export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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',
);
});
});

Expand All @@ -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',
);
});
});
});

0 comments on commit c890eb1

Please sign in to comment.