Adds interaction tests for components

This commit is contained in:
Josh Perez 2022-06-24 12:52:48 -04:00 committed by GitHub
parent f9fb09b734
commit c28313bd0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 952 additions and 27 deletions

View file

@ -4,6 +4,8 @@
import type { Meta, Story } from '@storybook/react';
import * as React from 'react';
import { isBoolean } from 'lodash';
import { expect } from '@storybook/jest';
import { within, userEvent } from '@storybook/testing-library';
import { action } from '@storybook/addon-actions';
@ -55,6 +57,7 @@ export default {
control: { type: 'radio' },
options: conversationTypeMap,
},
onClick: { action: true },
size: {
control: false,
},
@ -114,6 +117,12 @@ export const Default = Template.bind({});
Default.args = createProps({
avatarPath: '/fixtures/giphy-GVNvOUpeYmI7e.gif',
});
Default.play = async ({ args, canvasElement }) => {
const canvas = within(canvasElement);
const [avatar] = canvas.getAllByRole('button');
await userEvent.click(avatar);
await expect(args.onClick).toHaveBeenCalled();
};
Default.story = {
name: 'Avatar',
};