mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 03:11:49 +08:00
37 lines
857 B
Plaintext
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/>',
|
|
}),
|
|
};
|
|
``` |