Fix windows tests for normalizeStoryPath

This commit is contained in:
Ian VanSchooten 2021-12-04 19:09:13 -08:00
parent 595ce8a450
commit e65bd0ecb7

View File

@ -3,54 +3,27 @@ import { normalizeStoryPath } from '../paths';
describe('paths - normalizeStoryPath()', () => {
it('returns a path starting with "./" unchanged', () => {
const filename = `./src/Comp.story.js`;
const filename = `.${path.sep}${path.join('src', 'Comp.story.js')}`;
expect(normalizeStoryPath(filename)).toEqual(filename);
});
it('returns a path starting with "../" unchanged', () => {
const filename = `../src/Comp.story.js`;
const filename = path.join('..', 'src', 'Comp.story.js');
expect(normalizeStoryPath(filename)).toEqual(filename);
});
it('adds "./" to a normalized relative path', () => {
const filename = `src/Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(`./${filename}`);
const filename = path.join('src', 'Comp.story.js');
expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);
});
it('adds "./" to a hidden folder', () => {
const filename = `.storybook/Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(`./${filename}`);
const filename = path.join('.storybook', 'Comp.story.js');
expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);
});
it('adds "./" to a hidden file', () => {
const filename = `.Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(`./${filename}`);
});
describe('windows paths', () => {
it('returns a path starting with ".\\" unchanged', () => {
const filename = `.\\src\\Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(filename);
});
it('returns a path starting with "..\\" unchanged', () => {
const filename = `..\\src\\Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(filename);
});
it('adds ".{path.sep}" to a normalized relative path', () => {
const filename = `src\\Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);
});
it('adds ".{path.sep}" to a hidden folder', () => {
const filename = `.storybook\\Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);
});
it('adds ".{path.sep}" to a hidden file', () => {
const filename = `.Comp.story.js`;
expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`);
});
});
});