mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
CSF3: Auto-title respect file system capitalization
This commit is contained in:
parent
7ffc170f71
commit
b222fc189d
@ -28,7 +28,7 @@ describe('autoTitle', () => {
|
|||||||
it('match with no titlePrefix', () => {
|
it('match with no titlePrefix', () => {
|
||||||
expect(
|
expect(
|
||||||
auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path' }, options))
|
auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path' }, options))
|
||||||
).toMatchInlineSnapshot(`To/File`);
|
).toMatchInlineSnapshot(`to/file`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with titlePrefix', () => {
|
it('match with titlePrefix', () => {
|
||||||
@ -37,7 +37,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to/file.stories.js',
|
'./path/to/file.stories.js',
|
||||||
normalizeStoriesEntry({ directory: './path', titlePrefix: 'atoms' }, options)
|
normalizeStoriesEntry({ directory: './path', titlePrefix: 'atoms' }, options)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`Atoms/To/File`);
|
).toMatchInlineSnapshot(`atoms/to/file`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with trailing duplicate', () => {
|
it('match with trailing duplicate', () => {
|
||||||
@ -46,7 +46,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to/button/button.stories.js',
|
'./path/to/button/button.stories.js',
|
||||||
normalizeStoriesEntry({ directory: './path' }, options)
|
normalizeStoriesEntry({ directory: './path' }, options)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`To/Button`);
|
).toMatchInlineSnapshot(`to/button`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with trailing index', () => {
|
it('match with trailing index', () => {
|
||||||
@ -55,7 +55,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to/button/index.stories.js',
|
'./path/to/button/index.stories.js',
|
||||||
normalizeStoriesEntry({ directory: './path' }, options)
|
normalizeStoriesEntry({ directory: './path' }, options)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`To/Button`);
|
).toMatchInlineSnapshot(`to/button/index`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with hyphen path', () => {
|
it('match with hyphen path', () => {
|
||||||
@ -64,7 +64,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to-my/file.stories.js',
|
'./path/to-my/file.stories.js',
|
||||||
normalizeStoriesEntry({ directory: './path' }, options)
|
normalizeStoriesEntry({ directory: './path' }, options)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`To My/File`);
|
).toMatchInlineSnapshot(`to-my/file`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with underscore path', () => {
|
it('match with underscore path', () => {
|
||||||
@ -73,7 +73,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to_my/file.stories.js',
|
'./path/to_my/file.stories.js',
|
||||||
normalizeStoriesEntry({ directory: './path' }, options)
|
normalizeStoriesEntry({ directory: './path' }, options)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`To My/File`);
|
).toMatchInlineSnapshot(`to_my/file`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with windows path', () => {
|
it('match with windows path', () => {
|
||||||
@ -82,7 +82,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to_my/file.stories.js',
|
'./path/to_my/file.stories.js',
|
||||||
normalizeStoriesEntry({ directory: '.\\path' }, winOptions)
|
normalizeStoriesEntry({ directory: '.\\path' }, winOptions)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`To My/File`);
|
).toMatchInlineSnapshot(`to_my/file`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ describe('autoTitle', () => {
|
|||||||
it('match with no titlePrefix', () => {
|
it('match with no titlePrefix', () => {
|
||||||
expect(
|
expect(
|
||||||
auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path/' }, options))
|
auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path/' }, options))
|
||||||
).toMatchInlineSnapshot(`To/File`);
|
).toMatchInlineSnapshot(`to/file`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with titlePrefix', () => {
|
it('match with titlePrefix', () => {
|
||||||
@ -99,7 +99,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to/file.stories.js',
|
'./path/to/file.stories.js',
|
||||||
normalizeStoriesEntry({ directory: './path/', titlePrefix: 'atoms' }, options)
|
normalizeStoriesEntry({ directory: './path/', titlePrefix: 'atoms' }, options)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`Atoms/To/File`);
|
).toMatchInlineSnapshot(`atoms/to/file`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with hyphen path', () => {
|
it('match with hyphen path', () => {
|
||||||
@ -108,7 +108,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to-my/file.stories.js',
|
'./path/to-my/file.stories.js',
|
||||||
normalizeStoriesEntry({ directory: './path/' }, options)
|
normalizeStoriesEntry({ directory: './path/' }, options)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`To My/File`);
|
).toMatchInlineSnapshot(`to-my/file`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with underscore path', () => {
|
it('match with underscore path', () => {
|
||||||
@ -117,7 +117,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to_my/file.stories.js',
|
'./path/to_my/file.stories.js',
|
||||||
normalizeStoriesEntry({ directory: './path/' }, options)
|
normalizeStoriesEntry({ directory: './path/' }, options)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`To My/File`);
|
).toMatchInlineSnapshot(`to_my/file`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('match with windows path', () => {
|
it('match with windows path', () => {
|
||||||
@ -126,7 +126,7 @@ describe('autoTitle', () => {
|
|||||||
'./path/to_my/file.stories.js',
|
'./path/to_my/file.stories.js',
|
||||||
normalizeStoriesEntry({ directory: '.\\path\\' }, winOptions)
|
normalizeStoriesEntry({ directory: '.\\path\\' }, winOptions)
|
||||||
)
|
)
|
||||||
).toMatchInlineSnapshot(`To My/File`);
|
).toMatchInlineSnapshot(`to_my/file`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -57,7 +57,7 @@ export const autoTitleFromSpecifier = (fileName: string, entry: NormalizedStorie
|
|||||||
const suffix = normalizedFileName.replace(directory, '');
|
const suffix = normalizedFileName.replace(directory, '');
|
||||||
const titleAndSuffix = slash(pathJoin([titlePrefix, suffix]));
|
const titleAndSuffix = slash(pathJoin([titlePrefix, suffix]));
|
||||||
let path = titleAndSuffix.split('/');
|
let path = titleAndSuffix.split('/');
|
||||||
path = stripExtension(path).map(startCase);
|
path = stripExtension(path);
|
||||||
path = removeRedundantFilename(path);
|
path = removeRedundantFilename(path);
|
||||||
return path.join('/');
|
return path.join('/');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user