storybook/docs/snippets/vue/my-component-play-function-with-selectevent.js.mdx
2021-10-08 19:32:55 +01:00

37 lines
857 B
Plaintext

```js
// MyComponent.stories.js
// These are placeholders until the addon-interaction is out
import userEvent from '@testing-library/user-event';
import { screen, fireEvent } from '@testing-library/vue';
import MyComponent from './MyComponent.vue';
export default {
component: MyComponent,
};
// Queries the element by it's role and fires the event
export const ExampleChangeEvent = {
play: async () => {
const dropdown = screen.getByRole('listbox');
await fireEvent.change(dropdown, { target: { value: 'One Item'} });
await sleep(2000);
await fireEvent.change(dropdown, { target: { value: 'Another Item' } });
await sleep(2000);
await fireEvent.change(dropdown, {
target: { value: 'Yet another item' },
});
},
render: () => ({
components: { MyComponent },
template: '<MyComponent/>',
}),
};
```