From e65bd0ecb7cb420d7d0f19ac47f81ad2e88ed91c Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Sat, 4 Dec 2021 19:09:13 -0800 Subject: [PATCH] Fix windows tests for normalizeStoryPath --- .../src/utils/__tests__/paths.test.ts | 41 ++++--------------- 1 file changed, 7 insertions(+), 34 deletions(-) diff --git a/lib/core-common/src/utils/__tests__/paths.test.ts b/lib/core-common/src/utils/__tests__/paths.test.ts index b1422aee080..bbb1e714710 100644 --- a/lib/core-common/src/utils/__tests__/paths.test.ts +++ b/lib/core-common/src/utils/__tests__/paths.test.ts @@ -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}`); - }); + expect(normalizeStoryPath(filename)).toEqual(`.${path.sep}${filename}`); }); });