Revert "make paths.test windows compatible"

This reverts commit 5c03abfa136b22254318bc7b55a6512a47d25e91.
This commit is contained in:
Yann Braga 2023-03-09 15:26:18 +01:00
parent 5c03abfa13
commit f84c3217c3

View File

@ -4,12 +4,9 @@ import { normalizeStoryPath, getProjectRoot } from '../paths';
jest.mock('find-up');
// Windows uses backslashes, which causes failures that won't happen on Unix based systems, so we just normalize the paths
const normalizeSeparator = (str: string) => str.replace(/\//g, path.sep);
describe('paths - normalizeStoryPath()', () => {
it('returns a path starting with "./" unchanged', () => {
const filename = normalizeSeparator(`./${path.join('src', 'Comp.story.js')}`);
const filename = `.${path.sep}${path.join('src', 'Comp.story.js')}`;
expect(normalizeStoryPath(filename)).toEqual(filename);
});
@ -30,17 +27,17 @@ describe('paths - normalizeStoryPath()', () => {
it('adds "./" to a normalized relative path', () => {
const filename = path.join('src', 'Comp.story.js');
expect(normalizeStoryPath(filename)).toEqual(normalizeSeparator(`./${filename}`));
expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);
});
it('adds "./" to a hidden folder', () => {
const filename = path.join('.storybook', 'Comp.story.js');
expect(normalizeStoryPath(filename)).toEqual(normalizeSeparator(`./${filename}`));
expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);
});
it('adds "./" to a hidden file', () => {
const filename = `.Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(normalizeSeparator(`./${filename}`));
expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);
});
});
@ -49,25 +46,25 @@ describe('getProjectRoot', () => {
it('should return the root directory containing a .git directory', () => {
mockedFindUp.sync.mockImplementation((name) =>
name === ('.git' as any) ? normalizeSeparator('/path/to/root') : undefined
name === ('.git' as any) ? '/path/to/root' : undefined
);
expect(getProjectRoot()).toBe(normalizeSeparator('/path/to'));
expect(getProjectRoot()).toBe('/path/to');
});
it('should return the root directory containing a .svn directory if there is no .git directory', () => {
mockedFindUp.sync.mockImplementation((name) =>
name === ('.svn' as any) ? normalizeSeparator('/path/to/root') : undefined
name === ('.svn' as any) ? '/path/to/root' : undefined
);
expect(getProjectRoot()).toBe(normalizeSeparator('/path/to'));
expect(getProjectRoot()).toBe('/path/to');
});
it('should return the root directory containing a .yarn directory if there is no .git or .svn directory', () => {
mockedFindUp.sync.mockImplementation((name) =>
name === ('.yarn' as any) ? normalizeSeparator('/path/to/root') : undefined
name === ('.yarn' as any) ? '/path/to/root' : undefined
);
expect(getProjectRoot()).toBe(normalizeSeparator('/path/to'));
expect(getProjectRoot()).toBe('/path/to');
});
});