diff --git a/src/components/ActionTooltip/__tests__/ActionTooltip.tsx b/src/components/ActionTooltip/__tests__/ActionTooltip.tsx index d443fb5cd5..338026f763 100644 --- a/src/components/ActionTooltip/__tests__/ActionTooltip.tsx +++ b/src/components/ActionTooltip/__tests__/ActionTooltip.tsx @@ -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') { diff --git a/src/components/Alert/Alert.test.tsx b/src/components/Alert/Alert.test.tsx index b8e645fb3a..5f89bb3cf5 100644 --- a/src/components/Alert/Alert.test.tsx +++ b/src/components/Alert/Alert.test.tsx @@ -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'; diff --git a/src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx b/src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx index 19413ec3c4..63177dde65 100644 --- a/src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx +++ b/src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx @@ -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 = [ diff --git a/src/components/Button/__tests__/Button.test.tsx b/src/components/Button/__tests__/Button.test.tsx index 08218bec66..f4608150bd 100644 --- a/src/components/Button/__tests__/Button.test.tsx +++ b/src/components/Button/__tests__/Button.test.tsx @@ -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'; diff --git a/src/components/Card/__tests__/Card.test.tsx b/src/components/Card/__tests__/Card.test.tsx index 981ec8358e..d1c4597aa7 100644 --- a/src/components/Card/__tests__/Card.test.tsx +++ b/src/components/Card/__tests__/Card.test.tsx @@ -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'; diff --git a/src/components/Checkbox/__tests__/Checkbox.test.tsx b/src/components/Checkbox/__tests__/Checkbox.test.tsx index 0cb70b3282..d0d75146d8 100644 --- a/src/components/Checkbox/__tests__/Checkbox.test.tsx +++ b/src/components/Checkbox/__tests__/Checkbox.test.tsx @@ -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'; diff --git a/src/components/ClipboardButton/__tests__/ClipboardButton.test.tsx b/src/components/ClipboardButton/__tests__/ClipboardButton.test.tsx index 710f645b8f..627b8c1e16 100644 --- a/src/components/ClipboardButton/__tests__/ClipboardButton.test.tsx +++ b/src/components/ClipboardButton/__tests__/ClipboardButton.test.tsx @@ -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', () => { diff --git a/src/components/Dialog/__tests__/Dialog.test.tsx b/src/components/Dialog/__tests__/Dialog.test.tsx index b823b0a2f6..70e42dbd75 100644 --- a/src/components/Dialog/__tests__/Dialog.test.tsx +++ b/src/components/Dialog/__tests__/Dialog.test.tsx @@ -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', () => { diff --git a/src/components/Disclosure/__tests__/Disclosure .test.tsx b/src/components/Disclosure/__tests__/Disclosure .test.tsx index 40d4c2ad49..205050bf01 100644 --- a/src/components/Disclosure/__tests__/Disclosure .test.tsx +++ b/src/components/Disclosure/__tests__/Disclosure .test.tsx @@ -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'; diff --git a/src/components/DropdownMenu/DropdownMenu.test.tsx b/src/components/DropdownMenu/DropdownMenu.test.tsx index 9946163e29..4fa56da11b 100644 --- a/src/components/DropdownMenu/DropdownMenu.test.tsx +++ b/src/components/DropdownMenu/DropdownMenu.test.tsx @@ -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', () => { diff --git a/src/components/Link/__tests__/Link.test.tsx b/src/components/Link/__tests__/Link.test.tsx index ac7701c80c..fb1232a22e 100644 --- a/src/components/Link/__tests__/Link.test.tsx +++ b/src/components/Link/__tests__/Link.test.tsx @@ -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', () => { diff --git a/src/components/List/__tests__/ListItem.test.tsx b/src/components/List/__tests__/ListItem.test.tsx index 883ded03be..ddb5425cdc 100644 --- a/src/components/List/__tests__/ListItem.test.tsx +++ b/src/components/List/__tests__/ListItem.test.tsx @@ -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'; diff --git a/src/components/Persona/__tests__/Persona.test.tsx b/src/components/Persona/__tests__/Persona.test.tsx index f2fb2ac1ae..e88b998c13 100644 --- a/src/components/Persona/__tests__/Persona.test.tsx +++ b/src/components/Persona/__tests__/Persona.test.tsx @@ -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'; diff --git a/src/components/Popover/__tests__/Popover.test.tsx b/src/components/Popover/__tests__/Popover.test.tsx index de7f13532b..5d6103f27f 100644 --- a/src/components/Popover/__tests__/Popover.test.tsx +++ b/src/components/Popover/__tests__/Popover.test.tsx @@ -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'; diff --git a/src/components/Popup/__tests__/Popup.test.tsx b/src/components/Popup/__tests__/Popup.test.tsx index 543bdf403b..3304296b4c 100644 --- a/src/components/Popup/__tests__/Popup.test.tsx +++ b/src/components/Popup/__tests__/Popup.test.tsx @@ -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'; diff --git a/src/components/Radio/__tests__/Radio.test.tsx b/src/components/Radio/__tests__/Radio.test.tsx index 5000bd1872..b8a85572b3 100644 --- a/src/components/Radio/__tests__/Radio.test.tsx +++ b/src/components/Radio/__tests__/Radio.test.tsx @@ -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'; diff --git a/src/components/RadioButton/__tests__/RadioButton.test.tsx b/src/components/RadioButton/__tests__/RadioButton.test.tsx index 4afbf00cd9..38bc065625 100644 --- a/src/components/RadioButton/__tests__/RadioButton.test.tsx +++ b/src/components/RadioButton/__tests__/RadioButton.test.tsx @@ -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'; diff --git a/src/components/RadioGroup/__tests__/RadioGroup.test.tsx b/src/components/RadioGroup/__tests__/RadioGroup.test.tsx index 654268c489..8f8d8fb881 100644 --- a/src/components/RadioGroup/__tests__/RadioGroup.test.tsx +++ b/src/components/RadioGroup/__tests__/RadioGroup.test.tsx @@ -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'; diff --git a/src/components/Select/__tests__/Select.base-actions.test.tsx b/src/components/Select/__tests__/Select.base-actions.test.tsx index 5103d0cada..5cd3a2f4fe 100644 --- a/src/components/Select/__tests__/Select.base-actions.test.tsx +++ b/src/components/Select/__tests__/Select.base-actions.test.tsx @@ -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'; diff --git a/src/components/Select/__tests__/Select.clear.test.tsx b/src/components/Select/__tests__/Select.clear.test.tsx index 7204220a05..f01d2d4f7f 100644 --- a/src/components/Select/__tests__/Select.clear.test.tsx +++ b/src/components/Select/__tests__/Select.clear.test.tsx @@ -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'; diff --git a/src/components/Select/__tests__/Select.filter.test.tsx b/src/components/Select/__tests__/Select.filter.test.tsx index 0cbf5e3962..da995d3a04 100644 --- a/src/components/Select/__tests__/Select.filter.test.tsx +++ b/src/components/Select/__tests__/Select.filter.test.tsx @@ -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'; diff --git a/src/components/Select/__tests__/Select.muitiple.test.tsx b/src/components/Select/__tests__/Select.muitiple.test.tsx index f70262ea09..b115e0afac 100644 --- a/src/components/Select/__tests__/Select.muitiple.test.tsx +++ b/src/components/Select/__tests__/Select.muitiple.test.tsx @@ -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, diff --git a/src/components/Select/__tests__/Select.single.test.tsx b/src/components/Select/__tests__/Select.single.test.tsx index d43e0fdbe2..04964bd784 100644 --- a/src/components/Select/__tests__/Select.single.test.tsx +++ b/src/components/Select/__tests__/Select.single.test.tsx @@ -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, diff --git a/src/components/Select/__tests__/utils.tsx b/src/components/Select/__tests__/utils.tsx index 7542fbbc22..c2238eac63 100644 --- a/src/components/Select/__tests__/utils.tsx +++ b/src/components/Select/__tests__/utils.tsx @@ -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'; diff --git a/src/components/Sheet/__tests__/Sheet.test.tsx b/src/components/Sheet/__tests__/Sheet.test.tsx index 19424f9f43..7223d0395a 100644 --- a/src/components/Sheet/__tests__/Sheet.test.tsx +++ b/src/components/Sheet/__tests__/Sheet.test.tsx @@ -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'; diff --git a/src/components/Switch/__tests__/Switch.test.tsx b/src/components/Switch/__tests__/Switch.test.tsx index d2fe48e240..9c7b96ecdd 100644 --- a/src/components/Switch/__tests__/Switch.test.tsx +++ b/src/components/Switch/__tests__/Switch.test.tsx @@ -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'; diff --git a/src/components/Table/__tests__/Table.test.tsx b/src/components/Table/__tests__/Table.test.tsx index 8c524fe857..3a0f0bf490 100644 --- a/src/components/Table/__tests__/Table.test.tsx +++ b/src/components/Table/__tests__/Table.test.tsx @@ -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'; diff --git a/src/components/Tabs/__tests__/Tabs.test.tsx b/src/components/Tabs/__tests__/Tabs.test.tsx index a1b9684766..c525e20c81 100644 --- a/src/components/Tabs/__tests__/Tabs.test.tsx +++ b/src/components/Tabs/__tests__/Tabs.test.tsx @@ -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'; diff --git a/src/components/Tabs/__tests__/TabsItem.test.tsx b/src/components/Tabs/__tests__/TabsItem.test.tsx index 6324be07ec..4cea9ea221 100644 --- a/src/components/Tabs/__tests__/TabsItem.test.tsx +++ b/src/components/Tabs/__tests__/TabsItem.test.tsx @@ -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'; diff --git a/src/components/Toaster/__mocks__/fireAnimationEndEvent.ts b/src/components/Toaster/__mocks__/fireAnimationEndEvent.ts index 7fa6fd7fd8..c023e6ffbc 100644 --- a/src/components/Toaster/__mocks__/fireAnimationEndEvent.ts +++ b/src/components/Toaster/__mocks__/fireAnimationEndEvent.ts @@ -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}); diff --git a/src/components/Toaster/__mocks__/getToast.ts b/src/components/Toaster/__mocks__/getToast.ts index 2ef1a11232..17e99a2dd3 100644 --- a/src/components/Toaster/__mocks__/getToast.ts +++ b/src/components/Toaster/__mocks__/getToast.ts @@ -1,4 +1,4 @@ -import {screen} from '@testing-library/react'; +import {screen} from '../../../../test-utils/utils'; import {fireAnimationEndEvent} from './fireAnimationEndEvent'; diff --git a/src/components/Toaster/__mocks__/tick.ts b/src/components/Toaster/__mocks__/tick.ts index 341ab47c6e..41f02a7357 100644 --- a/src/components/Toaster/__mocks__/tick.ts +++ b/src/components/Toaster/__mocks__/tick.ts @@ -1,4 +1,4 @@ -import {act} from '@testing-library/react'; +import {act} from '../../../../test-utils/utils'; import {fireAnimationEndEvent} from './fireAnimationEndEvent'; diff --git a/src/components/Toaster/__tests__/ToasterProvider.test.tsx b/src/components/Toaster/__tests__/ToasterProvider.test.tsx index 91031f662d..0e99a42b13 100644 --- a/src/components/Toaster/__tests__/ToasterProvider.test.tsx +++ b/src/components/Toaster/__tests__/ToasterProvider.test.tsx @@ -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'; diff --git a/src/components/Toc/__tests__/Toc.test.tsx b/src/components/Toc/__tests__/Toc.test.tsx index 0b6460e059..6f56f9ecbd 100644 --- a/src/components/Toc/__tests__/Toc.test.tsx +++ b/src/components/Toc/__tests__/Toc.test.tsx @@ -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 = [ diff --git a/src/components/Tooltip/__tests__/Tooltip.test.tsx b/src/components/Tooltip/__tests__/Tooltip.test.tsx index 68e83b4155..a609d74dd4 100644 --- a/src/components/Tooltip/__tests__/Tooltip.test.tsx +++ b/src/components/Tooltip/__tests__/Tooltip.test.tsx @@ -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') { diff --git a/src/components/User/__tests__/User.test.tsx b/src/components/User/__tests__/User.test.tsx index 98b87868e0..d72481075f 100644 --- a/src/components/User/__tests__/User.test.tsx +++ b/src/components/User/__tests__/User.test.tsx @@ -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', () => { diff --git a/src/components/controls/TextArea/__tests__/TextArea.test.tsx b/src/components/controls/TextArea/__tests__/TextArea.test.tsx index b5b918b6a6..47aa3f9740 100644 --- a/src/components/controls/TextArea/__tests__/TextArea.test.tsx +++ b/src/components/controls/TextArea/__tests__/TextArea.test.tsx @@ -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'; diff --git a/src/components/controls/TextInput/__tests__/TextInput.input.test.tsx b/src/components/controls/TextInput/__tests__/TextInput.input.test.tsx index d997ca7ead..b09d635883 100644 --- a/src/components/controls/TextInput/__tests__/TextInput.input.test.tsx +++ b/src/components/controls/TextInput/__tests__/TextInput.input.test.tsx @@ -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'; diff --git a/src/components/utils/__tests__/xpath.test.tsx b/src/components/utils/__tests__/xpath.test.tsx index d17b2656f0..8b72daf8aa 100644 --- a/src/components/utils/__tests__/xpath.test.tsx +++ b/src/components/utils/__tests__/xpath.test.tsx @@ -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 { diff --git a/src/hooks/useFocusWithin/useFocusWithin.test.tsx b/src/hooks/useFocusWithin/useFocusWithin.test.tsx index b8ae6a690a..e8ca2a3464 100644 --- a/src/hooks/useFocusWithin/useFocusWithin.test.tsx +++ b/src/hooks/useFocusWithin/useFocusWithin.test.tsx @@ -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', () => { diff --git a/src/hooks/useOutsideClick/__tests__/useOutsideClick.test.tsx b/src/hooks/useOutsideClick/__tests__/useOutsideClick.test.tsx index ffbe05b77f..c53dd54fe4 100644 --- a/src/hooks/useOutsideClick/__tests__/useOutsideClick.test.tsx +++ b/src/hooks/useOutsideClick/__tests__/useOutsideClick.test.tsx @@ -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 () => { diff --git a/src/hooks/useSelect/__tests__/useOpenState.test.tsx b/src/hooks/useSelect/__tests__/useOpenState.test.tsx index fb0abac40c..74b3171df9 100644 --- a/src/hooks/useSelect/__tests__/useOpenState.test.tsx +++ b/src/hooks/useSelect/__tests__/useOpenState.test.tsx @@ -1,5 +1,4 @@ -import {act, renderHook} from '@testing-library/react'; - +import {act, renderHook} from '../../../../test-utils/utils'; import type {UseOpenProps} from '../types'; import {useOpenState} from '../useOpenState'; diff --git a/src/hooks/useViewportSize/__tests__/useViewportSize.test.tsx b/src/hooks/useViewportSize/__tests__/useViewportSize.test.tsx index 8b5c5a742b..bed044f0cf 100644 --- a/src/hooks/useViewportSize/__tests__/useViewportSize.test.tsx +++ b/src/hooks/useViewportSize/__tests__/useViewportSize.test.tsx @@ -1,6 +1,5 @@ -import {act, fireEvent, renderHook} from '@testing-library/react'; - import {useViewportSize} from '..'; +import {act, fireEvent, renderHook} from '../../../../test-utils/utils'; test('Check useViewportSize correct work', () => { const view = renderHook(() => useViewportSize()); diff --git a/test-utils/utils.tsx b/test-utils/utils.tsx new file mode 100644 index 0000000000..06b7ea103c --- /dev/null +++ b/test-utils/utils.tsx @@ -0,0 +1,35 @@ +import React from 'react'; + +import {render} from '@testing-library/react'; +import type {RenderOptions} from '@testing-library/react'; + +import type {ThemeContextProps} from '../src'; +import {ThemeContext} from '../src/components/theme/ThemeContext'; + +const themeContextValue: ThemeContextProps = { + direction: 'ltr', + theme: 'light', + themeValue: 'light', +}; + +function Providers({children}: {children: React.ReactElement}) { + return {children}; +} + +function createWrapper(Component: React.JSXElementConstructor<{children: React.ReactElement}>) { + return function Wrapper({children}: {children: React.ReactElement}) { + return ( + + {children} + + ); + }; +} + +function customRender(ui: React.ReactElement, options?: RenderOptions) { + const wrapper = options?.wrapper ? createWrapper(options.wrapper) : Providers; + return render(ui, {...options, wrapper}); +} + +export * from '@testing-library/react'; +export {customRender as render}; diff --git a/tsconfig.json b/tsconfig.json index a793a34bd8..9785028296 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,6 +18,6 @@ "include": [ "src/**/*.ts", "src/**/*.tsx", - "test-utils/setup-tests-after.ts" + "test-utils/*" ] -} \ No newline at end of file +}