Skip to content

Commit

Permalink
[#65] Additionnal feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Dec 1, 2023
1 parent c327551 commit be1911d
Showing 1 changed file with 21 additions and 33 deletions.
54 changes: 21 additions & 33 deletions src/components/formio/fieldset.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expect} from '@storybook/jest';
import {Meta, StoryFn, StoryObj} from '@storybook/react';
import {Meta, StoryObj} from '@storybook/react';
import {within} from '@storybook/testing-library';

import {withFormik} from '@/sb-decorators';
Expand All @@ -12,58 +12,46 @@ export default {
decorators: [withFormik],
parameters: {
modal: {noModal: true},
// https://github.com/bbbtech/storybook-formik/issues/51#issuecomment-1136668271
docs: {
inlineStories: false,
iframeHeight: 150,
},
},
args: {
type: 'textfield',
children: '<any children />',
},
} as Meta<typeof Fieldset>;

type Story = StoryObj<typeof Fieldset>;

const Template: StoryFn<typeof Fieldset> = args => (
<Fieldset {...args}>
<div>{args.children || '<any children />'}</div>
</Fieldset>
);

export const WithoutLabel: Story = {
render: Template,

args: {
label: '',
},
};

export const WithToolTip: Story = {
render: Template,

args: {
label: 'With tooltip',
tooltip: 'Hiya!',
},
};

export const WithErrors: Story = Template.bind([]);
WithErrors.parameters = {
formik: {
initialValues: {someField: ''},
initialErrors: {someField: 'Some error'},
export const WithErrors: Story = {
parameters: {
formik: {
initialValues: {someField: ''},
initialErrors: {someField: 'Some error'},
},
},
args: {
label: 'Errors must be displayed',
children: <input type="text" />,
field: 'someField',
},
argTypes: {
children: {table: {disable: true}},
},

play: async ({canvasElement}) => {
const canvas = within(canvasElement);
await expect(canvas.queryByText('Some error')).toBeInTheDocument();
},
};
WithErrors.args = {
label: 'Errors must be displayed',
children: <input type="text" />,
field: 'someField',
};
WithErrors.argTypes = {
children: {table: {disable: true}},
};
WithErrors.play = async ({canvasElement}) => {
const canvas = within(canvasElement);
await expect(canvas.queryByText('Some error')).toBeInTheDocument();
};

0 comments on commit be1911d

Please sign in to comment.