mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-05 06:21:15 +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', () => {
|
||||
expect(
|
||||
auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path' }, options))
|
||||
).toMatchInlineSnapshot(`To/File`);
|
||||
).toMatchInlineSnapshot(`to/file`);
|
||||
});
|
||||
|
||||
it('match with titlePrefix', () => {
|
||||
@ -37,7 +37,7 @@ describe('autoTitle', () => {
|
||||
'./path/to/file.stories.js',
|
||||
normalizeStoriesEntry({ directory: './path', titlePrefix: 'atoms' }, options)
|
||||
)
|
||||
).toMatchInlineSnapshot(`Atoms/To/File`);
|
||||
).toMatchInlineSnapshot(`atoms/to/file`);
|
||||
});
|
||||
|
||||
it('match with trailing duplicate', () => {
|
||||
@ -46,7 +46,7 @@ describe('autoTitle', () => {
|
||||
'./path/to/button/button.stories.js',
|
||||
normalizeStoriesEntry({ directory: './path' }, options)
|
||||
)
|
||||
).toMatchInlineSnapshot(`To/Button`);
|
||||
).toMatchInlineSnapshot(`to/button`);
|
||||
});
|
||||
|
||||
it('match with trailing index', () => {
|
||||
@ -55,7 +55,7 @@ describe('autoTitle', () => {
|
||||
'./path/to/button/index.stories.js',
|
||||
normalizeStoriesEntry({ directory: './path' }, options)
|
||||
)
|
||||
).toMatchInlineSnapshot(`To/Button`);
|
||||
).toMatchInlineSnapshot(`to/button/index`);
|
||||
});
|
||||
|
||||
it('match with hyphen path', () => {
|
||||
@ -64,7 +64,7 @@ describe('autoTitle', () => {
|
||||
'./path/to-my/file.stories.js',
|
||||
normalizeStoriesEntry({ directory: './path' }, options)
|
||||
)
|
||||
).toMatchInlineSnapshot(`To My/File`);
|
||||
).toMatchInlineSnapshot(`to-my/file`);
|
||||
});
|
||||
|
||||
it('match with underscore path', () => {
|
||||
@ -73,7 +73,7 @@ describe('autoTitle', () => {
|
||||
'./path/to_my/file.stories.js',
|
||||
normalizeStoriesEntry({ directory: './path' }, options)
|
||||
)
|
||||
).toMatchInlineSnapshot(`To My/File`);
|
||||
).toMatchInlineSnapshot(`to_my/file`);
|
||||
});
|
||||
|
||||
it('match with windows path', () => {
|
||||
@ -82,7 +82,7 @@ describe('autoTitle', () => {
|
||||
'./path/to_my/file.stories.js',
|
||||
normalizeStoriesEntry({ directory: '.\\path' }, winOptions)
|
||||
)
|
||||
).toMatchInlineSnapshot(`To My/File`);
|
||||
).toMatchInlineSnapshot(`to_my/file`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -90,7 +90,7 @@ describe('autoTitle', () => {
|
||||
it('match with no titlePrefix', () => {
|
||||
expect(
|
||||
auto('./path/to/file.stories.js', normalizeStoriesEntry({ directory: './path/' }, options))
|
||||
).toMatchInlineSnapshot(`To/File`);
|
||||
).toMatchInlineSnapshot(`to/file`);
|
||||
});
|
||||
|
||||
it('match with titlePrefix', () => {
|
||||
@ -99,7 +99,7 @@ describe('autoTitle', () => {
|
||||
'./path/to/file.stories.js',
|
||||
normalizeStoriesEntry({ directory: './path/', titlePrefix: 'atoms' }, options)
|
||||
)
|
||||
).toMatchInlineSnapshot(`Atoms/To/File`);
|
||||
).toMatchInlineSnapshot(`atoms/to/file`);
|
||||
});
|
||||
|
||||
it('match with hyphen path', () => {
|
||||
@ -108,7 +108,7 @@ describe('autoTitle', () => {
|
||||
'./path/to-my/file.stories.js',
|
||||
normalizeStoriesEntry({ directory: './path/' }, options)
|
||||
)
|
||||
).toMatchInlineSnapshot(`To My/File`);
|
||||
).toMatchInlineSnapshot(`to-my/file`);
|
||||
});
|
||||
|
||||
it('match with underscore path', () => {
|
||||
@ -117,7 +117,7 @@ describe('autoTitle', () => {
|
||||
'./path/to_my/file.stories.js',
|
||||
normalizeStoriesEntry({ directory: './path/' }, options)
|
||||
)
|
||||
).toMatchInlineSnapshot(`To My/File`);
|
||||
).toMatchInlineSnapshot(`to_my/file`);
|
||||
});
|
||||
|
||||
it('match with windows path', () => {
|
||||
@ -126,7 +126,7 @@ describe('autoTitle', () => {
|
||||
'./path/to_my/file.stories.js',
|
||||
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 titleAndSuffix = slash(pathJoin([titlePrefix, suffix]));
|
||||
let path = titleAndSuffix.split('/');
|
||||
path = stripExtension(path).map(startCase);
|
||||
path = stripExtension(path);
|
||||
path = removeRedundantFilename(path);
|
||||
return path.join('/');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user