Skip to content

Commit

Permalink
test: use custom render function
Browse files Browse the repository at this point in the history
  • Loading branch information
ValeraS committed Jan 10, 2024
1 parent 92a029e commit dbadb3f
Show file tree
Hide file tree
Showing 45 changed files with 85 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/components/ActionTooltip/__tests__/ActionTooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {createEvent, fireEvent, render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {createEvent, fireEvent, render, screen} from '../../../../test-utils/utils';
import {ActionTooltip} from '../ActionTooltip';

export function fireAnimationEndEvent(el: Node | Window, animationName = 'animation') {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Alert/Alert.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../test-utils/utils';
import {Flex} from '../layout';

import {Alert} from './Alert';
Expand Down
3 changes: 1 addition & 2 deletions src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

import {render, screen} from '@testing-library/react';

import {render, screen} from '../../../../test-utils/utils';
import {Breadcrumbs} from '../Breadcrumbs';

const items = [
Expand Down
2 changes: 1 addition & 1 deletion src/components/Button/__tests__/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';

import {Gear} from '@gravity-ui/icons';
import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Button} from '../Button';
import type {ButtonPin, ButtonProps, ButtonSize, ButtonView} from '../Button';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Card/__tests__/Card.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Button} from '../../Button';
import type {CardSize, CardTheme, CardType, CardView} from '../Card';
import {Card} from '../Card';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Checkbox/__tests__/Checkbox.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Checkbox} from '../Checkbox';
import type {CheckboxSize} from '../Checkbox';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {ClipboardButton} from '../ClipboardButton';

describe('ClipboardButton', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/Dialog/__tests__/Dialog.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

import {render, screen} from '@testing-library/react';

import {render, screen} from '../../../../test-utils/utils';
import {Dialog} from '../Dialog';

test('should label dialog with header text', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Disclosure/__tests__/Disclosure .test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Disclosure} from '../Disclosure';
import type {DisclosureSize} from '../Disclosure';

Expand Down
3 changes: 2 additions & 1 deletion src/components/DropdownMenu/DropdownMenu.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../test-utils/utils';

import {DropdownMenu} from './DropdownMenu';

test('do not trigger `onOpenToggle` on mount', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/Link/__tests__/Link.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

import {render, screen} from '@testing-library/react';

import {render, screen} from '../../../../test-utils/utils';
import {Link} from '../Link';

describe('Link', () => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/List/__tests__/ListItem.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

import {render, screen} from '@testing-library/react';

import {render, screen} from '../../../../test-utils/utils';
import {ListItem} from '../components';
import type {ListItemData, ListItemProps} from '../types';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Persona/__tests__/Persona.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {queryByAttribute, render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {queryByAttribute, render, screen} from '../../../../test-utils/utils';
import {getAvatarDisplayText} from '../../Avatar';
import {Persona} from '../Persona';
import i18n from '../i18n';
Expand Down
3 changes: 1 addition & 2 deletions src/components/Popover/__tests__/Popover.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';

import {act, fireEvent, render, screen} from '@testing-library/react';

import {setupTimersMock} from '../../../../test-utils/setupTimersMock';
import {act, fireEvent, render, screen} from '../../../../test-utils/utils';
import {Popover} from '../Popover';
import {PopoverBehavior, delayByBehavior} from '../config';
import type {PopoverProps} from '../types';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Popup/__tests__/Popup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Button} from '../../Button/Button';
import {Popup} from '../Popup';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Radio/__tests__/Radio.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Radio} from '../Radio';
import type {RadioSize} from '../Radio';

Expand Down
2 changes: 1 addition & 1 deletion src/components/RadioButton/__tests__/RadioButton.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';

import {render, screen, within} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {RadioButton} from '../';
import type {RadioButtonOption, RadioButtonProps, RadioButtonSize, RadioButtonWidth} from '../';
import {render, screen, within} from '../../../../test-utils/utils';
import {block} from '../../../components/utils/cn';

const qaId = 'radio-button-component';
Expand Down
2 changes: 1 addition & 1 deletion src/components/RadioGroup/__tests__/RadioGroup.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen, within} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen, within} from '../../../../test-utils/utils';
import {RadioGroup} from '../RadioGroup';
import type {RadioGroupDirection, RadioGroupOption, RadioGroupSize} from '../RadioGroup';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';

import {act, render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {SelectQa} from '..';
import {act, render, screen} from '../../../../test-utils/utils';
import {ListQa} from '../../List';
import {DEFAULT_VIRTUALIZATION_THRESHOLD, QUICK_SEARCH_TIMEOUT} from '../constants';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/__tests__/Select.clear.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {cleanup} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {cleanup} from '../../../../test-utils/utils';
import {SelectQa} from '../constants';
import type {SelectProps} from '../types';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/__tests__/Select.filter.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {cleanup} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {cleanup} from '../../../../test-utils/utils';
import {TextInput} from '../../controls';
import type {SelectOption, SelectProps} from '../types';

Expand Down
3 changes: 2 additions & 1 deletion src/components/Select/__tests__/Select.muitiple.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {cleanup} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {cleanup} from '../../../../test-utils/utils';

import {
DEFAULT_OPTIONS,
GROUPED_OPTIONS,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Select/__tests__/Select.single.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {cleanup} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {cleanup} from '../../../../test-utils/utils';

import {
DEFAULT_OPTIONS,
GROUPED_OPTIONS,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Select/__tests__/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';

import {act, render} from '@testing-library/react';
import range from 'lodash/range';

import {Select} from '..';
import type {SelectOption, SelectOptionGroup, SelectProps, SelectRenderControlProps} from '..';
import {act, render} from '../../../../test-utils/utils';
import {MobileProvider} from '../../mobile';
import {selectControlBlock, selectControlButtonBlock, selectListBlock} from '../constants';

Expand Down
3 changes: 1 addition & 2 deletions src/components/Sheet/__tests__/Sheet.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

import {render, screen} from '@testing-library/react';

import {render, screen} from '../../../../test-utils/utils';
import {Sheet} from '../Sheet';
import {sheetBlock} from '../constants';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Switch/__tests__/Switch.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Switch} from '../Switch';

const qaId = 'switch';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Table/__tests__/Table.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen, within} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen, within} from '../../../../test-utils/utils';
import {Table} from '../Table';

import {columns, data} from './utils';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/__tests__/Tabs.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Tabs, TabsDirection} from '../Tabs';
import type {TabsItemProps, TabsSize} from '../Tabs';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/__tests__/TabsItem.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';

import {Flame} from '@gravity-ui/icons';
import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {TabsItem} from '../TabsItem';

const tabId = 'tab-id';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toaster/__mocks__/fireAnimationEndEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {createEvent, fireEvent} from '@testing-library/react';
import {createEvent, fireEvent} from '../../../../test-utils/utils';

export function fireAnimationEndEvent(el: Node | Window, animationName: string) {
const ev = createEvent.animationEnd(el, {animationName});
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toaster/__mocks__/getToast.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {screen} from '@testing-library/react';
import {screen} from '../../../../test-utils/utils';

import {fireAnimationEndEvent} from './fireAnimationEndEvent';

Expand Down
2 changes: 1 addition & 1 deletion src/components/Toaster/__mocks__/tick.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {act} from '@testing-library/react';
import {act} from '../../../../test-utils/utils';

import {fireAnimationEndEvent} from './fireAnimationEndEvent';

Expand Down
3 changes: 1 addition & 2 deletions src/components/Toaster/__tests__/ToasterProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

import {act, fireEvent, render, screen, within} from '@testing-library/react';

import {act, fireEvent, render, screen, within} from '../../../../test-utils/utils';
import {Modal} from '../../../components/Modal/Modal';
import {ToasterProvider} from '../Provider/ToasterProvider';
import {ToasterComponent} from '../ToasterComponent/ToasterComponent';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toc/__tests__/Toc.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';
import {Toc} from '../Toc';

const defaultItems = [
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tooltip/__tests__/Tooltip.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {createEvent, fireEvent, render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {createEvent, fireEvent, render, screen} from '../../../../test-utils/utils';
import {Tooltip} from '../Tooltip';

export function fireAnimationEndEvent(el: Node | Window, animationName = 'animation') {
Expand Down
3 changes: 1 addition & 2 deletions src/components/User/__tests__/User.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

import {render, screen} from '@testing-library/react';

import {render, screen} from '../../../../test-utils/utils';
import {User} from '../User';

describe('User', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {fireEvent, render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {fireEvent, render, screen} from '../../../../../test-utils/utils';
import {CONTROL_ERROR_MESSAGE_QA} from '../../utils';
import {TextArea} from '../TextArea';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';

import {fireEvent, queryHelpers, render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {fireEvent, queryHelpers, render, screen} from '../../../../../test-utils/utils';
import {CONTROL_ERROR_ICON_QA, CONTROL_ERROR_MESSAGE_QA} from '../../utils';
import {TextInput} from '../TextInput';

Expand Down
3 changes: 1 addition & 2 deletions src/components/utils/__tests__/xpath.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import React from 'react';

import {render, screen} from '@testing-library/react';

import {render, screen} from '../../../../test-utils/utils';
import {getXpath, withoutClassMods} from '../xpath';

class XpathBuilder {
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useFocusWithin/useFocusWithin.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';

import {act, render, screen, waitFor} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import ReactDom from 'react-dom';

import {act, render, screen, waitFor} from '../../../test-utils/utils';

import {useFocusWithin} from './useFocusWithin';

describe('useFocusWithin', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useOutsideClick/__tests__/useOutsideClick.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';

import {render, screen} from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import {render, screen} from '../../../../test-utils/utils';

import {Demo} from './Demo';

test('Check useOutsideClick correct work', async () => {
Expand Down
Loading

0 comments on commit dbadb3f

Please sign in to comment.