storybook/docs/snippets/angular/my-component-play-function-with-clickevent.mdx.mdx
2021-10-05 02:08:12 +01:00

29 lines
789 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/angular';
import userEvent from '@testing-library/user-event';
import { MyComponent } from './MyComponent.component';
<!-- 👇 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'));
}} />
```