mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-10 12:47:49 +00:00
feat: configurable filename separator for split command (#610)
* Make file path separator configurable in split command * chore: add tests for the file name separator * chore: update snapshots * docs: split separator option description * chore: code style fixes
This commit is contained in:
committed by
GitHub
parent
3e8b08449d
commit
1f10c7cd77
@@ -28,6 +28,7 @@ describe('#split', () => {
|
||||
{
|
||||
entrypoint: filePath,
|
||||
outDir: openapiDir,
|
||||
separator: '_',
|
||||
}
|
||||
);
|
||||
|
||||
@@ -41,12 +42,31 @@ describe('#split', () => {
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
it('should use the correct separator', async () => {
|
||||
const filePath = "./packages/cli/src/commands/split/__tests__/fixtures/spec.json";
|
||||
|
||||
const utils = require('../../../utils');
|
||||
jest.spyOn(utils, 'pathToFilename').mockImplementation(() => 'newFilePath');
|
||||
|
||||
await handleSplit (
|
||||
{
|
||||
entrypoint: filePath,
|
||||
outDir: openapiDir,
|
||||
separator: '_',
|
||||
}
|
||||
);
|
||||
|
||||
expect(utils.pathToFilename).toBeCalledWith(expect.anything(), '_');
|
||||
utils.pathToFilename.mockRestore();
|
||||
});
|
||||
|
||||
it('should have correct path with paths', () => {
|
||||
const openapi = require("./fixtures/spec.json");
|
||||
|
||||
jest.spyOn(openapiCore, 'slash').mockImplementation(() => 'paths/test.yaml');
|
||||
jest.spyOn(path, 'relative').mockImplementation(() => 'paths/test.yaml');
|
||||
iteratePathItems(openapi.paths, openapiDir, path.join(openapiDir, 'paths'), componentsFiles);
|
||||
iteratePathItems(openapi.paths, openapiDir, path.join(openapiDir, 'paths'), componentsFiles, '_');
|
||||
|
||||
expect(openapiCore.slash).toHaveBeenCalledWith('paths/test.yaml');
|
||||
expect(path.relative).toHaveBeenCalledWith('test', 'test/paths/test.yaml');
|
||||
|
||||
Reference in New Issue
Block a user