mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-10 12:47:49 +00:00
fix: backslashes in $refs to paths on split command from windows (#493)
This commit is contained in:
committed by
GitHub
parent
bd119b612c
commit
713683e0ae
32
packages/cli/src/commands/split/__tests__/index.test.ts
Normal file
32
packages/cli/src/commands/split/__tests__/index.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { iteratePaths } from '../index';
|
||||
import * as path from 'path';
|
||||
import * as openapiCore from '@redocly/openapi-core';
|
||||
|
||||
jest.mock('../../../utils', () => ({
|
||||
...jest.requireActual('../../../utils'),
|
||||
writeYaml: jest.fn(),
|
||||
}));
|
||||
|
||||
describe('#split', () => {
|
||||
it('should have correct paths for mac', () => {
|
||||
const pathsDir = 'test/paths';
|
||||
const openapiDir = 'test';
|
||||
|
||||
jest.spyOn(openapiCore, 'slash').mockImplementation(() => 'paths/test.yaml');
|
||||
jest.spyOn(path, 'relative').mockImplementation(() => 'paths/test.yaml');
|
||||
iteratePaths(require("./fixtures/spec.json"), pathsDir, openapiDir);
|
||||
expect(openapiCore.slash).toHaveBeenCalledWith('paths/test.yaml');
|
||||
expect(path.relative).toHaveBeenCalledWith('test', 'test/paths/test.yaml');
|
||||
});
|
||||
|
||||
it('should have correct paths for windows', () => {
|
||||
const pathsDir = 'test\\paths';
|
||||
const openapiDir = 'test';
|
||||
|
||||
jest.spyOn(openapiCore, 'slash').mockImplementation(() => 'paths\\test.yaml');
|
||||
jest.spyOn(path, 'relative').mockImplementation(() => 'paths\\test.yaml');
|
||||
iteratePaths(require("./fixtures/spec.json"), pathsDir, openapiDir);
|
||||
expect(openapiCore.slash).toHaveBeenCalledWith('paths\\test.yaml');
|
||||
expect(path.relative).toHaveBeenCalledWith('test', 'test\\paths/test.yaml');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user