mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 02:11:49 +08:00
29 lines
781 B
Plaintext
29 lines
781 B
Plaintext
```md
|
|
<!-- MyComponent.stories.mdx -->
|
|
|
|
import { Meta, Story } from '@storybook/addon-docs';
|
|
|
|
<!-- These are placeholders until the addon-interaction is out -->
|
|
|
|
import { screen, fireEvent } from '@testing-library/react';
|
|
|
|
import userEvent from '@testing-library/user-event';
|
|
|
|
import { MyComponent } from './MyComponent.js';
|
|
|
|
<!-- 👇 Marking the onButtonClick with this configuration will log the event in the Actions panel -->
|
|
|
|
<Meta title="ClickExamples" component={MyComponent} argTypes={{ onButtonClick: { action: true }}/>
|
|
|
|
<Story
|
|
name="ClickExample"
|
|
play={async () => {
|
|
await userEvent.click(screen.getByTestId('data-testid'));
|
|
}} />
|
|
|
|
<Story
|
|
name="FireEventExample"
|
|
play={async () => {
|
|
await fireEvent.click(screen.getByTestId('data-testid'));
|
|
}} />
|
|
``` |