mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 03:11:49 +08:00
34 lines
938 B
Plaintext
34 lines
938 B
Plaintext
```ts
|
|
// MyComponent.stories.ts
|
|
|
|
// These are placeholders until the addon-interaction is out
|
|
import userEvent from '@testing-library/user-event';
|
|
import { screen, fireEvent } from '@testing-library/angular';
|
|
|
|
import { MyComponent } from './MyComponent.component';
|
|
|
|
export default {
|
|
component: MyComponent,
|
|
};
|
|
|
|
// This is a placeholder mocked sleep function to be updated once the addon-interactions is out.
|
|
function sleep(ms: any) {
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
}
|
|
|
|
export const ExampleChangeEvent = {
|
|
play: async () => {
|
|
await fireEvent.change(screen.getByTestId('select'), {
|
|
target: { value: 'One Item' },
|
|
});
|
|
await sleep(2000);
|
|
await fireEvent.change(screen.getByTestId('select'), {
|
|
target: { value: 'Another Item' },
|
|
});
|
|
await sleep(2000);
|
|
await fireEvent.change(screen.getByTestId('select'), {
|
|
target: { value: 'Yet another item' },
|
|
});
|
|
},
|
|
};
|
|
``` |