2023-05-20 15:07:12 +10:00
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { configureStore, createSlice } from '@reduxjs/toolkit';
|
2023-05-15 20:53:17 +10:00
|
|
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
|
|
|
2023-05-15 20:54:22 +10:00
|
|
|
import InfoDialogComponent from './InfoDialogComponent';
|
2023-05-20 15:07:12 +10:00
|
|
|
import { InfoDialogStateProps } from 'features/InfoDialog/infoDialogSlice';
|
|
|
|
|
|
|
|
const MockedState = {
|
|
|
|
// Copied from Redux DevTools from browser
|
|
|
|
infoDialog: {
|
|
|
|
isOpen: false,
|
|
|
|
InfoDialogDetails: {
|
|
|
|
id: 0,
|
|
|
|
name: '',
|
|
|
|
genera: '',
|
|
|
|
image: '',
|
|
|
|
types: [],
|
|
|
|
height: 0,
|
|
|
|
weight: 0,
|
|
|
|
genderRatio: 0,
|
|
|
|
description: '',
|
|
|
|
abilities: [],
|
|
|
|
stats: [],
|
|
|
|
evolutionChain: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
interface MockStoreProps {
|
|
|
|
InfoDialogState: InfoDialogStateProps;
|
|
|
|
children: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
const mockSlice = (infoDialogState: {
|
|
|
|
InfoDialogState: InfoDialogStateProps;
|
|
|
|
}) => {
|
|
|
|
return createSlice({
|
|
|
|
name: 'infoDialog',
|
|
|
|
initialState: infoDialogState,
|
|
|
|
reducers: {},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const mockStore = (infoDialogState: {
|
|
|
|
InfoDialogState: InfoDialogStateProps;
|
|
|
|
}) => {
|
|
|
|
return configureStore({
|
|
|
|
reducer: {
|
|
|
|
infoDialog: mockSlice(infoDialogState).reducer,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
const Mockstore: React.FC<MockStoreProps> = ({ InfoDialogState, children }) => (
|
|
|
|
<Provider store={mockStore({ InfoDialogState })}>{children}</Provider>
|
|
|
|
);
|
2023-05-10 00:13:33 +10:00
|
|
|
|
2023-05-15 20:53:17 +10:00
|
|
|
const meta: Meta<typeof InfoDialogComponent> = {
|
2023-05-10 00:13:33 +10:00
|
|
|
title: 'Component/InfoDialogComponent',
|
|
|
|
component: InfoDialogComponent,
|
2023-05-20 15:07:12 +10:00
|
|
|
decorators: [
|
|
|
|
(story: () => React.ReactNode) => (
|
|
|
|
<div style={{ padding: '3rem' }}>{story()}</div>
|
|
|
|
),
|
|
|
|
],
|
|
|
|
tags: ['autodocs'],
|
|
|
|
excludeStories: /.*MockedState$/,
|
2023-05-15 20:53:17 +10:00
|
|
|
};
|
2023-05-10 00:13:33 +10:00
|
|
|
|
2023-05-15 20:53:17 +10:00
|
|
|
export default meta;
|
|
|
|
type Story = StoryObj<typeof InfoDialogComponent>;
|
2023-05-10 00:13:33 +10:00
|
|
|
|
2023-05-15 20:53:17 +10:00
|
|
|
export const Duduo: Story = {
|
2023-05-20 15:07:12 +10:00
|
|
|
decorators: [
|
|
|
|
(story: () => React.ReactNode) => (
|
|
|
|
<Mockstore InfoDialogState={MockedState.infoDialog}>{story()}</Mockstore>
|
|
|
|
),
|
|
|
|
],
|
2023-05-15 20:53:17 +10:00
|
|
|
args: {
|
|
|
|
openDialog: true,
|
|
|
|
id: 84,
|
|
|
|
name: 'Doduo',
|
|
|
|
genera: 'Twin Bird Pokémon',
|
|
|
|
image:
|
|
|
|
'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/dream-world/84.svg',
|
|
|
|
types: ['normal', 'flying'],
|
|
|
|
height: 14,
|
|
|
|
weight: 392,
|
|
|
|
genderRatio: 4,
|
|
|
|
description:
|
|
|
|
'A bird that makes up for its poor flying with its fast foot speed. Leaves giant footprints.',
|
|
|
|
abilities: ['run-away', 'early-bird', 'tangled-feet'],
|
|
|
|
stats: [
|
|
|
|
{ stat__name: 'hp', stat__value: 35 },
|
|
|
|
{ stat__name: 'attack', stat__value: 85 },
|
|
|
|
{ stat__name: 'defense', stat__value: 45 },
|
|
|
|
{ stat__name: 'special-attack', stat__value: 35 },
|
|
|
|
{ stat__name: 'special-defense', stat__value: 35 },
|
|
|
|
{ stat__name: 'speed', stat__value: 75 },
|
|
|
|
],
|
|
|
|
evolutionChain: [
|
|
|
|
{
|
|
|
|
types: ['normal', 'flying'],
|
2023-05-17 21:50:34 +10:00
|
|
|
image_url:
|
2023-05-15 20:53:17 +10:00
|
|
|
'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/dream-world/84.svg',
|
|
|
|
name: 'Doduo',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Dodrio',
|
|
|
|
types: ['normal', 'flying'],
|
2023-05-17 21:50:34 +10:00
|
|
|
image_url:
|
2023-05-15 20:53:17 +10:00
|
|
|
'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/dream-world/85.svg',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2023-05-10 00:13:33 +10:00
|
|
|
};
|