mirror of https://github.com/buster-so/buster.git
mock router for my components
This commit is contained in:
parent
a6179bff2e
commit
80df59acdb
|
@ -1,4 +1,5 @@
|
||||||
import type { StorybookConfig } from '@storybook/nextjs';
|
import type { StorybookConfig } from '@storybook/nextjs';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
const config: StorybookConfig = {
|
const config: StorybookConfig = {
|
||||||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
||||||
|
@ -11,6 +12,14 @@ const config: StorybookConfig = {
|
||||||
name: '@storybook/nextjs',
|
name: '@storybook/nextjs',
|
||||||
options: {}
|
options: {}
|
||||||
},
|
},
|
||||||
staticDirs: ['../public']
|
staticDirs: ['../public'],
|
||||||
|
webpackFinal: async (config) => {
|
||||||
|
config.resolve = config.resolve || {};
|
||||||
|
config.resolve.alias = {
|
||||||
|
...(config.resolve.alias || {}),
|
||||||
|
'next/navigation': path.resolve(__dirname, './mocks/next-navigation.ts')
|
||||||
|
};
|
||||||
|
return config;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
// mocks/next-navigation.ts
|
||||||
|
export const useRouter = () => ({
|
||||||
|
push: () => {},
|
||||||
|
replace: () => {},
|
||||||
|
refresh: () => {},
|
||||||
|
back: () => {}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const usePathname = () => '/';
|
||||||
|
export const useSearchParams = () => new URLSearchParams();
|
||||||
|
export const useParams = () => ({});
|
|
@ -102,13 +102,6 @@ export const Disabled: Story = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AsChild: Story = {
|
|
||||||
args: {
|
|
||||||
asChild: true,
|
|
||||||
children: <a href="www.google.com">Link Button</a>
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const Loading: Story = {
|
export const Loading: Story = {
|
||||||
args: {
|
args: {
|
||||||
variant: 'default',
|
variant: 'default',
|
||||||
|
|
Loading…
Reference in New Issue