mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 05:11:06 +08:00
add more tests for new-frameworks utils
This commit is contained in:
parent
d85ce716f8
commit
77813f94b5
@ -1,4 +1,4 @@
|
|||||||
import { getBuilderInfo as _getBuilderInfo } from './utils';
|
import { getBuilderInfo as _getBuilderInfo, getNextjsAddonOptions } from './utils';
|
||||||
|
|
||||||
type GetBuilderInfoParams = Parameters<typeof _getBuilderInfo>[0];
|
type GetBuilderInfoParams = Parameters<typeof _getBuilderInfo>[0];
|
||||||
|
|
||||||
@ -11,27 +11,20 @@ describe('getBuilderInfo', () => {
|
|||||||
getBuilderInfo({
|
getBuilderInfo({
|
||||||
core: { builder: '@storybook/builder-webpack5' },
|
core: { builder: '@storybook/builder-webpack5' },
|
||||||
})
|
})
|
||||||
).toEqual({
|
).toEqual({ name: 'webpack5', options: {} });
|
||||||
name: 'webpack5',
|
|
||||||
options: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
getBuilderInfo({
|
getBuilderInfo({
|
||||||
core: {
|
core: {
|
||||||
builder: {
|
builder: {
|
||||||
name: '@storybook/builder-webpack5',
|
name: '@storybook/builder-webpack5',
|
||||||
options: {
|
options: { lazyCompilation: true },
|
||||||
lazyCompilation: true,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
).toEqual({
|
).toEqual({
|
||||||
name: 'webpack5',
|
name: 'webpack5',
|
||||||
options: {
|
options: { lazyCompilation: true },
|
||||||
lazyCompilation: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -40,10 +33,7 @@ describe('getBuilderInfo', () => {
|
|||||||
getBuilderInfo({
|
getBuilderInfo({
|
||||||
framework: '@storybook/react-webpack5',
|
framework: '@storybook/react-webpack5',
|
||||||
})
|
})
|
||||||
).toEqual({
|
).toEqual({ name: 'webpack5', options: {} });
|
||||||
name: 'webpack5',
|
|
||||||
options: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
getBuilderInfo({
|
getBuilderInfo({
|
||||||
@ -58,9 +48,7 @@ describe('getBuilderInfo', () => {
|
|||||||
})
|
})
|
||||||
).toEqual({
|
).toEqual({
|
||||||
name: 'webpack5',
|
name: 'webpack5',
|
||||||
options: {
|
options: { lazyCompilation: true },
|
||||||
lazyCompilation: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -69,27 +57,20 @@ describe('getBuilderInfo', () => {
|
|||||||
getBuilderInfo({
|
getBuilderInfo({
|
||||||
core: { builder: '@storybook/builder-vite' },
|
core: { builder: '@storybook/builder-vite' },
|
||||||
})
|
})
|
||||||
).toEqual({
|
).toEqual({ name: 'vite', options: {} });
|
||||||
name: 'vite',
|
|
||||||
options: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
getBuilderInfo({
|
getBuilderInfo({
|
||||||
core: {
|
core: {
|
||||||
builder: {
|
builder: {
|
||||||
name: '@storybook/builder-vite',
|
name: '@storybook/builder-vite',
|
||||||
options: {
|
options: { foo: 'bar' },
|
||||||
foo: 'bar',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
).toEqual({
|
).toEqual({
|
||||||
name: 'vite',
|
name: 'vite',
|
||||||
options: {
|
options: { foo: 'bar' },
|
||||||
foo: 'bar',
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -98,27 +79,40 @@ describe('getBuilderInfo', () => {
|
|||||||
getBuilderInfo({
|
getBuilderInfo({
|
||||||
framework: '@storybook/react-vite',
|
framework: '@storybook/react-vite',
|
||||||
})
|
})
|
||||||
).toEqual({
|
).toEqual({ name: 'vite', options: {} });
|
||||||
name: 'vite',
|
|
||||||
options: {},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
getBuilderInfo({
|
getBuilderInfo({
|
||||||
framework: {
|
framework: {
|
||||||
name: '@storybook/react-vite',
|
name: '@storybook/react-vite',
|
||||||
options: {
|
options: { builder: { foo: 'bar' } },
|
||||||
builder: {
|
|
||||||
foo: 'bar',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
).toEqual({
|
).toEqual({
|
||||||
name: 'vite',
|
name: 'vite',
|
||||||
|
options: { foo: 'bar' },
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getNextjsAddonOptions', () => {
|
||||||
|
it('should find storybook-addon-next and extract its options', () => {
|
||||||
|
expect(getNextjsAddonOptions(['foo', 'bar'])).toEqual({});
|
||||||
|
expect(getNextjsAddonOptions(['foo', 'storybook-addon-next'])).toEqual({});
|
||||||
|
expect(getNextjsAddonOptions(['foo', { name: 'storybook-addon-next' }])).toEqual({});
|
||||||
|
expect(getNextjsAddonOptions(['foo', { name: 'storybook-addon-next', options: {} }])).toEqual(
|
||||||
|
{}
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
getNextjsAddonOptions([
|
||||||
|
'foo',
|
||||||
|
{
|
||||||
|
name: 'storybook-addon-next',
|
||||||
options: {
|
options: {
|
||||||
foo: 'bar',
|
nextConfigPath: 'foo/bar',
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
])
|
||||||
|
).toEqual({ nextConfigPath: 'foo/bar' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user