mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-09 00:19:13 +08:00
33 lines
831 B
Plaintext
33 lines
831 B
Plaintext
```md
|
|
<!-- MyComponent.stories.mdx -->
|
|
|
|
import { Meta, Story } from '@storybook/addon-docs';
|
|
|
|
import { fireEvent,screen, userEvent } from '@storybook/testing-library';
|
|
|
|
import MyComponent from './MyComponent.vue';
|
|
|
|
<!-- 👇 Marking the onClick with this configuration will log the event in the Actions panel -->
|
|
|
|
<Meta title="ClickExamples" component={MyComponent} argTypes={{ onClick: { action: true }}/>
|
|
|
|
<Story
|
|
name="ClickExample"
|
|
play={async () => {
|
|
await userEvent.click(screen.getByRole('button'));
|
|
}}
|
|
render={()=>({
|
|
components: { MyComponent },
|
|
template: '<MyComponent/>',
|
|
})} />
|
|
|
|
<Story
|
|
name="FireEventExample"
|
|
play={async () => {
|
|
await fireEvent.click(screen.getByTestId('data-testid'));
|
|
}}
|
|
render={()=> ({
|
|
components: { MyComponent },
|
|
template: '<MyComponent/>',
|
|
})} />
|
|
``` |