Skip to content

Commit

Permalink
test: 🧪 (<PrefectureCheckboxFieldset>) 都道府県をフェッチしてチェックボックスを表示するコンポー…
Browse files Browse the repository at this point in the history
…ネントのストーリーを追加した。 (#20)
  • Loading branch information
ReoHakase committed May 25, 2024
1 parent 35fa18b commit 96626e9
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { action } from '@storybook/addon-actions';
import type { Meta, StoryObj } from '@storybook/react';
import { expect, fn, within } from '@storybook/test';
import { PrefectureCheckboxFieldset } from './PrefectureCheckboxFieldset';

type Story = StoryObj<typeof PrefectureCheckboxFieldset>;

const meta: Meta<typeof PrefectureCheckboxFieldset> = {
component: PrefectureCheckboxFieldset,
tags: ['autodocs'],
parameters: {
nextjs: {
appDirectory: true,
navigation: {
push: fn(async (...args: unknown[]) => action('nextRouter.push')(...args)),
pathname: '/all',
query: {
prefCodes: '11,24',
},
},
},
},
};

export default meta;

export const Default: Story = {
parameters: {
nextjs: {
navigation: {
query: {
prefCodes: '8,12,13,14',
},
},
},
},
play: async ({ canvasElement }) => {
// TODO: RESAS APIからのレスポンスをモックする
const canvas = within(canvasElement);
const checkboxes = await canvas.findAllByRole('checkbox');
expect(checkboxes).toHaveLength(47);
},
};

0 comments on commit 96626e9

Please sign in to comment.