diff --git a/src/components/BackgroundImage/__tests__/BackgroundImage.test.tsx b/src/components/BackgroundImage/__tests__/BackgroundImage.test.tsx index 4326a66d3..6f2aae286 100644 --- a/src/components/BackgroundImage/__tests__/BackgroundImage.test.tsx +++ b/src/components/BackgroundImage/__tests__/BackgroundImage.test.tsx @@ -3,7 +3,9 @@ import React from 'react'; import {render, screen} from '@testing-library/react'; import {testCustomClassName, testCustomStyle} from '../../../../test-utils/shared/common'; +import {testSourceProps} from '../../../../test-utils/shared/image'; import {BackgroundImageProps} from '../../../models'; +import {getQaAttrubutes} from '../../../utils'; import BackgroundImage from '../BackgroundImage'; const qa = 'background-image-component'; @@ -11,6 +13,8 @@ const qa = 'background-image-component'; const imageSrc = 'https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/images/img-gray.png'; +const qaAttributes = getQaAttrubutes(qa, 'image-desktop-source-compressed'); + describe('BackgroundImage', () => { test('Render BackgroundImage by default', async () => { render(); @@ -21,17 +25,19 @@ describe('BackgroundImage', () => { }); test('add image as src prop', () => { - render(); - const component = screen.getByRole('img'); - - expect(component).toHaveAttribute('src', imageSrc); + testSourceProps({ + component: BackgroundImage, + props: {src: imageSrc, qa}, + options: {qaId: qaAttributes.imageDesktopSourceCompressed}, + }); }); test('add image as desktop prop', () => { - render(); - const component = screen.getByRole('img'); - - expect(component).toHaveAttribute('src', imageSrc); + testSourceProps({ + component: BackgroundImage, + props: {desktop: imageSrc, qa}, + options: {qaId: qaAttributes.imageDesktopSourceCompressed}, + }); }); test('should hide image', () => { diff --git a/src/components/BackgroundMedia/__tests__/BackgroundMedia.test.tsx b/src/components/BackgroundMedia/__tests__/BackgroundMedia.test.tsx index 5fe0a0423..10fbe2f36 100644 --- a/src/components/BackgroundMedia/__tests__/BackgroundMedia.test.tsx +++ b/src/components/BackgroundMedia/__tests__/BackgroundMedia.test.tsx @@ -109,10 +109,10 @@ describe('BackgroundMedia', () => { test('render image', () => { const imageQaAttributes = getQaAttrubutes( qaAttributes.mediaImageBackgroundImage, - 'image-display-source', + 'image-desktop-source-compressed', ); render(); - const component = screen.getByTestId(imageQaAttributes.imageDisplaySource); + const component = screen.getByTestId(imageQaAttributes.imageDesktopSourceCompressed); expect(component).toBeInTheDocument(); }); diff --git a/src/components/Button/__tests__/Button.test.tsx b/src/components/Button/__tests__/Button.test.tsx index a3064bece..a7afd6ec7 100644 --- a/src/components/Button/__tests__/Button.test.tsx +++ b/src/components/Button/__tests__/Button.test.tsx @@ -2,9 +2,8 @@ import React from 'react'; import {ButtonSize} from '@gravity-ui/uikit'; import {render, screen} from '@testing-library/react'; -import userEvent from '@testing-library/user-event'; -import {testCustomClassName} from '../../../../test-utils/shared/common'; +import {testCustomClassName, testOnClick} from '../../../../test-utils/shared/common'; import {ButtonImagePosition, ButtonTheme} from '../../../models'; import Button, {ButtonProps} from '../Button'; import {ICON_QA} from '../utils'; @@ -63,14 +62,10 @@ describe('Button', () => { }); test('call onClick', async () => { - const user = userEvent.setup(); - const handleOnClick = jest.fn(); - render(