From dccbc43986b4fedecfe412ab4136e58986038232 Mon Sep 17 00:00:00 2001 From: literat Date: Tue, 17 Dec 2024 17:40:44 +0100 Subject: [PATCH] Test(web-react): Use Jest's automock functionality to share useIcon mock between tests --- .../Accordion/__tests__/AccordionHeader.test.tsx | 4 ++-- .../Accordion/__tests__/AccordionItem.test.tsx | 4 ++-- .../Accordion/__tests__/UncontrolledAccordion.test.tsx | 4 ++-- .../src/components/Alert/__tests__/Alert.test.tsx | 10 ++-------- .../Breadcrumbs/__tests__/Breadcrumbs.test.tsx | 4 ++-- .../Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx | 4 ++-- .../src/components/Button/__tests__/Button.test.tsx | 3 +-- .../ButtonLink/__tests__/ButtonLink.test.tsx | 3 +-- .../Dropdown/__tests__/DropdownTrigger.test.tsx | 4 ++-- .../FileUploader/__tests__/FileUploader.test.tsx | 4 ++-- .../FileUploader/__tests__/FileUploaderInput.test.tsx | 4 ++-- .../FileUploader/__tests__/FileUploaderList.test.tsx | 3 +-- .../Header/__tests__/HeaderDialogCloseButton.test.tsx | 4 ++-- .../Header/__tests__/HeaderMobileActions.test.tsx | 4 ++-- .../src/components/Icon/__tests__/Icon.test.tsx | 4 ++-- .../src/components/Item/__tests__/Item.test.tsx | 4 ++-- .../Modal/__tests__/ModalCloseButton.test.tsx | 4 ++-- .../components/Modal/__tests__/ModalHeader.test.tsx | 4 ++-- .../Pagination/__tests__/PaginationButtonLink.test.tsx | 4 ++-- .../Pagination/__tests__/PaginationLinkNext.test.tsx | 4 ++-- .../__tests__/PaginationLinkPrevious.test.tsx | 4 ++-- .../__tests__/UncontrolledPagination.test.tsx | 3 +-- .../src/components/Select/__tests__/Select.test.tsx | 3 +-- .../src/components/Spinner/__tests__/Spinner.test.tsx | 10 ++-------- .../components/TextField/__tests__/TextField.test.tsx | 3 +-- .../src/components/Toast/__tests__/ToastBar.test.tsx | 4 ++-- .../Toast/__tests__/UncontrolledToast.test.tsx | 3 +-- .../UNSTABLE_Avatar/__tests__/UNSTABLE_Avatar.test.tsx | 10 ++-------- packages/web-react/src/hooks/__mocks__/useIcon.ts | 1 + packages/web-react/tests/index.ts | 1 - packages/web-react/tests/mocks/hooksMock.ts | 4 ---- packages/web-react/tests/mocks/index.ts | 1 - 32 files changed, 50 insertions(+), 80 deletions(-) create mode 100644 packages/web-react/src/hooks/__mocks__/useIcon.ts delete mode 100644 packages/web-react/tests/mocks/hooksMock.ts delete mode 100644 packages/web-react/tests/mocks/index.ts diff --git a/packages/web-react/src/components/Accordion/__tests__/AccordionHeader.test.tsx b/packages/web-react/src/components/Accordion/__tests__/AccordionHeader.test.tsx index f693c5fd20..23d6a623a1 100644 --- a/packages/web-react/src/components/Accordion/__tests__/AccordionHeader.test.tsx +++ b/packages/web-react/src/components/Accordion/__tests__/AccordionHeader.test.tsx @@ -1,11 +1,11 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import AccordionHeader from '../AccordionHeader'; import AccordionItem from '../AccordionItem'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('AccordionHeader', () => { classNamePrefixProviderTest(AccordionHeader, 'Accordion__itemHeader'); diff --git a/packages/web-react/src/components/Accordion/__tests__/AccordionItem.test.tsx b/packages/web-react/src/components/Accordion/__tests__/AccordionItem.test.tsx index 9454034d09..14941f3b20 100644 --- a/packages/web-react/src/components/Accordion/__tests__/AccordionItem.test.tsx +++ b/packages/web-react/src/components/Accordion/__tests__/AccordionItem.test.tsx @@ -1,13 +1,13 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import Accordion from '../Accordion'; import AccordionContent from '../AccordionContent'; import AccordionHeader from '../AccordionHeader'; import AccordionItem from '../AccordionItem'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('AccordionItem', () => { classNamePrefixProviderTest(AccordionItem, 'Accordion__item'); diff --git a/packages/web-react/src/components/Accordion/__tests__/UncontrolledAccordion.test.tsx b/packages/web-react/src/components/Accordion/__tests__/UncontrolledAccordion.test.tsx index d5712f35c5..1904ad306b 100644 --- a/packages/web-react/src/components/Accordion/__tests__/UncontrolledAccordion.test.tsx +++ b/packages/web-react/src/components/Accordion/__tests__/UncontrolledAccordion.test.tsx @@ -1,13 +1,13 @@ import '@testing-library/jest-dom'; import { fireEvent, render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import AccordionContent from '../AccordionContent'; import AccordionHeader from '../AccordionHeader'; import AccordionItem from '../AccordionItem'; import UncontrolledAccordion from '../UncontrolledAccordion'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('UncontrolledAccordion', () => { classNamePrefixProviderTest(UncontrolledAccordion, 'Accordion'); diff --git a/packages/web-react/src/components/Alert/__tests__/Alert.test.tsx b/packages/web-react/src/components/Alert/__tests__/Alert.test.tsx index 9e5f34bab7..e94f11133c 100644 --- a/packages/web-react/src/components/Alert/__tests__/Alert.test.tsx +++ b/packages/web-react/src/components/Alert/__tests__/Alert.test.tsx @@ -1,16 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { - useIconMock, - classNamePrefixProviderTest, - emotionColorPropsTest, - restPropsTest, - stylePropsTest, -} from '@local/tests'; +import { classNamePrefixProviderTest, emotionColorPropsTest, restPropsTest, stylePropsTest } from '@local/tests'; import Alert from '../Alert'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('Alert', () => { classNamePrefixProviderTest(Alert, 'Alert'); diff --git a/packages/web-react/src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx b/packages/web-react/src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx index a1548a1bdd..5582cfd853 100644 --- a/packages/web-react/src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx +++ b/packages/web-react/src/components/Breadcrumbs/__tests__/Breadcrumbs.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import Breadcrumbs from '../Breadcrumbs'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('Breadcrumbs', () => { classNamePrefixProviderTest(Breadcrumbs, 'Breadcrumbs'); diff --git a/packages/web-react/src/components/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx b/packages/web-react/src/components/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx index dba47e82b4..7854b644bd 100644 --- a/packages/web-react/src/components/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx +++ b/packages/web-react/src/components/Breadcrumbs/__tests__/BreadcrumbsItem.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import BreadcrumbsItem from '../BreadcrumbsItem'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('BreadcrumbsItem', () => { classNamePrefixProviderTest(BreadcrumbsItem, 'd-none'); diff --git a/packages/web-react/src/components/Button/__tests__/Button.test.tsx b/packages/web-react/src/components/Button/__tests__/Button.test.tsx index 127a9212de..b2407b336f 100644 --- a/packages/web-react/src/components/Button/__tests__/Button.test.tsx +++ b/packages/web-react/src/components/Button/__tests__/Button.test.tsx @@ -2,7 +2,6 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; import { - useIconMock, classNamePrefixProviderTest, actionButtonColorPropsTest, emotionColorPropsTest, @@ -13,7 +12,7 @@ import { } from '@local/tests'; import Button from '../Button'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('Button', () => { classNamePrefixProviderTest(Button, 'Button'); diff --git a/packages/web-react/src/components/ButtonLink/__tests__/ButtonLink.test.tsx b/packages/web-react/src/components/ButtonLink/__tests__/ButtonLink.test.tsx index aaf37dff37..11a804fc7d 100644 --- a/packages/web-react/src/components/ButtonLink/__tests__/ButtonLink.test.tsx +++ b/packages/web-react/src/components/ButtonLink/__tests__/ButtonLink.test.tsx @@ -2,7 +2,6 @@ import '@testing-library/jest-dom'; import { render, screen } from '@testing-library/react'; import React from 'react'; import { - useIconMock, classNamePrefixProviderTest, actionButtonColorPropsTest, emotionColorPropsTest, @@ -13,7 +12,7 @@ import { } from '@local/tests'; import ButtonLink from '../ButtonLink'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('ButtonLink', () => { classNamePrefixProviderTest(ButtonLink, 'Button'); diff --git a/packages/web-react/src/components/Dropdown/__tests__/DropdownTrigger.test.tsx b/packages/web-react/src/components/Dropdown/__tests__/DropdownTrigger.test.tsx index 3bcbd3580a..ab4212cbbb 100644 --- a/packages/web-react/src/components/Dropdown/__tests__/DropdownTrigger.test.tsx +++ b/packages/web-react/src/components/Dropdown/__tests__/DropdownTrigger.test.tsx @@ -1,11 +1,11 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, restPropsTest, stylePropsTest } from '@local/tests'; +import { restPropsTest, stylePropsTest } from '@local/tests'; import { Button } from '../../Button'; import DropdownTrigger from '../DropdownTrigger'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('DropdownTrigger', () => { stylePropsTest((props) => ); diff --git a/packages/web-react/src/components/FileUploader/__tests__/FileUploader.test.tsx b/packages/web-react/src/components/FileUploader/__tests__/FileUploader.test.tsx index f01c61e0d2..c13b8fb104 100644 --- a/packages/web-react/src/components/FileUploader/__tests__/FileUploader.test.tsx +++ b/packages/web-react/src/components/FileUploader/__tests__/FileUploader.test.tsx @@ -1,9 +1,9 @@ import '@testing-library/jest-dom'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import FileUploader from '../FileUploader'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('FileUploader', () => { classNamePrefixProviderTest(FileUploader, 'FileUploader'); diff --git a/packages/web-react/src/components/FileUploader/__tests__/FileUploaderInput.test.tsx b/packages/web-react/src/components/FileUploader/__tests__/FileUploaderInput.test.tsx index 4bdd074d4f..2c65d28591 100644 --- a/packages/web-react/src/components/FileUploader/__tests__/FileUploaderInput.test.tsx +++ b/packages/web-react/src/components/FileUploader/__tests__/FileUploaderInput.test.tsx @@ -1,11 +1,11 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; import { renderToString } from 'react-dom/server'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, validationTextPropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, validationTextPropsTest } from '@local/tests'; import FileUploaderInput from '../FileUploaderInput'; import '@testing-library/jest-dom'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('FileUploaderInput', () => { classNamePrefixProviderTest(FileUploaderInput, 'FileUploaderInput'); diff --git a/packages/web-react/src/components/FileUploader/__tests__/FileUploaderList.test.tsx b/packages/web-react/src/components/FileUploader/__tests__/FileUploaderList.test.tsx index 4b10324e1b..7a4123e95d 100644 --- a/packages/web-react/src/components/FileUploader/__tests__/FileUploaderList.test.tsx +++ b/packages/web-react/src/components/FileUploader/__tests__/FileUploaderList.test.tsx @@ -1,11 +1,10 @@ import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock } from '@local/tests'; import { SpiritFileUploaderAttachmentProps } from '../../../types'; import FileUploader from '../FileUploader'; import FileUploaderList from '../FileUploaderList'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('FileUploaderList', () => { const props = { diff --git a/packages/web-react/src/components/Header/__tests__/HeaderDialogCloseButton.test.tsx b/packages/web-react/src/components/Header/__tests__/HeaderDialogCloseButton.test.tsx index 999d0acc4f..8581921ccf 100644 --- a/packages/web-react/src/components/Header/__tests__/HeaderDialogCloseButton.test.tsx +++ b/packages/web-react/src/components/Header/__tests__/HeaderDialogCloseButton.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import HeaderDialogCloseButton from '../HeaderDialogCloseButton'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('HeaderDialogCloseButton', () => { classNamePrefixProviderTest(HeaderDialogCloseButton, 'HeaderDialogCloseButton'); diff --git a/packages/web-react/src/components/Header/__tests__/HeaderMobileActions.test.tsx b/packages/web-react/src/components/Header/__tests__/HeaderMobileActions.test.tsx index ecb7d9ff37..a2820c5b8c 100644 --- a/packages/web-react/src/components/Header/__tests__/HeaderMobileActions.test.tsx +++ b/packages/web-react/src/components/Header/__tests__/HeaderMobileActions.test.tsx @@ -1,11 +1,11 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import { HEADER_MENU_TOGGLE_LABEL_DEFAULT } from '../constants'; import HeaderMobileActions from '../HeaderMobileActions'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('HeaderMobileActions', () => { classNamePrefixProviderTest(HeaderMobileActions, 'HeaderMobileActions'); diff --git a/packages/web-react/src/components/Icon/__tests__/Icon.test.tsx b/packages/web-react/src/components/Icon/__tests__/Icon.test.tsx index feb621f58a..a04078b6a2 100644 --- a/packages/web-react/src/components/Icon/__tests__/Icon.test.tsx +++ b/packages/web-react/src/components/Icon/__tests__/Icon.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, restPropsTest, stylePropsTest } from '@local/tests'; +import { restPropsTest, stylePropsTest } from '@local/tests'; import Icon from '../Icon'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('Icon', () => { const AddIcon = (props: Record) => ; diff --git a/packages/web-react/src/components/Item/__tests__/Item.test.tsx b/packages/web-react/src/components/Item/__tests__/Item.test.tsx index 94bc90a151..a1d82534ca 100644 --- a/packages/web-react/src/components/Item/__tests__/Item.test.tsx +++ b/packages/web-react/src/components/Item/__tests__/Item.test.tsx @@ -1,11 +1,11 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock, restPropsTest, stylePropsTest } from '@local/tests'; +import { restPropsTest, stylePropsTest } from '@local/tests'; import { SpiritItemProps } from '../../../types'; import Item from '../Item'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('Item', () => { stylePropsTest(Item); diff --git a/packages/web-react/src/components/Modal/__tests__/ModalCloseButton.test.tsx b/packages/web-react/src/components/Modal/__tests__/ModalCloseButton.test.tsx index 9a9f66ce2c..e88a5ca075 100644 --- a/packages/web-react/src/components/Modal/__tests__/ModalCloseButton.test.tsx +++ b/packages/web-react/src/components/Modal/__tests__/ModalCloseButton.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { fireEvent, render, screen } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import ModalCloseButton from '../ModalCloseButton'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('ModalCloseButton', () => { classNamePrefixProviderTest(ModalCloseButton, 'Button'); diff --git a/packages/web-react/src/components/Modal/__tests__/ModalHeader.test.tsx b/packages/web-react/src/components/Modal/__tests__/ModalHeader.test.tsx index 1cb3e91456..8ac1b31ac1 100644 --- a/packages/web-react/src/components/Modal/__tests__/ModalHeader.test.tsx +++ b/packages/web-react/src/components/Modal/__tests__/ModalHeader.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render, screen } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import ModalHeader from '../ModalHeader'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('ModalHeader', () => { classNamePrefixProviderTest(ModalHeader, 'ModalHeader'); diff --git a/packages/web-react/src/components/Pagination/__tests__/PaginationButtonLink.test.tsx b/packages/web-react/src/components/Pagination/__tests__/PaginationButtonLink.test.tsx index 3f6ba66439..2bbe83f507 100644 --- a/packages/web-react/src/components/Pagination/__tests__/PaginationButtonLink.test.tsx +++ b/packages/web-react/src/components/Pagination/__tests__/PaginationButtonLink.test.tsx @@ -1,8 +1,8 @@ import '@testing-library/jest-dom'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import PaginationButtonLink from '../PaginationButtonLink'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('PaginationButtonLink', () => { classNamePrefixProviderTest(PaginationButtonLink, 'Button'); diff --git a/packages/web-react/src/components/Pagination/__tests__/PaginationLinkNext.test.tsx b/packages/web-react/src/components/Pagination/__tests__/PaginationLinkNext.test.tsx index 7fa9514fe9..90d3271ecb 100644 --- a/packages/web-react/src/components/Pagination/__tests__/PaginationLinkNext.test.tsx +++ b/packages/web-react/src/components/Pagination/__tests__/PaginationLinkNext.test.tsx @@ -1,8 +1,8 @@ import '@testing-library/jest-dom'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import PaginationLinkNext from '../PaginationLinkNext'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('PaginationLinkNext', () => { classNamePrefixProviderTest(PaginationLinkNext, 'Button'); diff --git a/packages/web-react/src/components/Pagination/__tests__/PaginationLinkPrevious.test.tsx b/packages/web-react/src/components/Pagination/__tests__/PaginationLinkPrevious.test.tsx index 6e1185c72b..7970c91598 100644 --- a/packages/web-react/src/components/Pagination/__tests__/PaginationLinkPrevious.test.tsx +++ b/packages/web-react/src/components/Pagination/__tests__/PaginationLinkPrevious.test.tsx @@ -1,8 +1,8 @@ import '@testing-library/jest-dom'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import PaginationLinkPrevious from '../PaginationLinkPrevious'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('PaginationLinkPrevious', () => { classNamePrefixProviderTest(PaginationLinkPrevious, 'Button'); diff --git a/packages/web-react/src/components/Pagination/__tests__/UncontrolledPagination.test.tsx b/packages/web-react/src/components/Pagination/__tests__/UncontrolledPagination.test.tsx index 41e269569a..b29a3bd6f1 100644 --- a/packages/web-react/src/components/Pagination/__tests__/UncontrolledPagination.test.tsx +++ b/packages/web-react/src/components/Pagination/__tests__/UncontrolledPagination.test.tsx @@ -1,9 +1,8 @@ import { fireEvent, render, screen } from '@testing-library/react'; import React from 'react'; -import { useIconMock } from '@local/tests'; import UncontrolledPagination from '../UncontrolledPagination'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('UncontrolledPagination', () => { const onPageChange = jest.fn(); diff --git a/packages/web-react/src/components/Select/__tests__/Select.test.tsx b/packages/web-react/src/components/Select/__tests__/Select.test.tsx index 428dfa3095..6e530e125d 100644 --- a/packages/web-react/src/components/Select/__tests__/Select.test.tsx +++ b/packages/web-react/src/components/Select/__tests__/Select.test.tsx @@ -2,7 +2,6 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; import { - useIconMock, classNamePrefixProviderTest, validationStatePropsTest, requiredPropsTest, @@ -12,7 +11,7 @@ import { } from '@local/tests'; import Select from '../Select'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('Select', () => { classNamePrefixProviderTest(Select, 'Select'); diff --git a/packages/web-react/src/components/Spinner/__tests__/Spinner.test.tsx b/packages/web-react/src/components/Spinner/__tests__/Spinner.test.tsx index 0716e97143..d17ac3f2e3 100644 --- a/packages/web-react/src/components/Spinner/__tests__/Spinner.test.tsx +++ b/packages/web-react/src/components/Spinner/__tests__/Spinner.test.tsx @@ -1,16 +1,10 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { - useIconMock, - classNamePrefixProviderTest, - textColorPropsTest, - restPropsTest, - stylePropsTest, -} from '@local/tests'; +import { classNamePrefixProviderTest, textColorPropsTest, restPropsTest, stylePropsTest } from '@local/tests'; import Spinner from '../Spinner'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('Spinner', () => { classNamePrefixProviderTest(Spinner, 'animation-spin-clockwise'); diff --git a/packages/web-react/src/components/TextField/__tests__/TextField.test.tsx b/packages/web-react/src/components/TextField/__tests__/TextField.test.tsx index dea922bbab..2d0ff6ca0e 100644 --- a/packages/web-react/src/components/TextField/__tests__/TextField.test.tsx +++ b/packages/web-react/src/components/TextField/__tests__/TextField.test.tsx @@ -2,7 +2,6 @@ import '@testing-library/jest-dom'; import { fireEvent, render, screen } from '@testing-library/react'; import React from 'react'; import { - useIconMock, classNamePrefixProviderTest, validationStatePropsTest, restPropsTest, @@ -12,7 +11,7 @@ import { import { TextFieldType } from '../../../types'; import TextField from '../TextField'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('TextField', () => { describe.each(['text', 'password', 'email'])('input type %s', (type) => { diff --git a/packages/web-react/src/components/Toast/__tests__/ToastBar.test.tsx b/packages/web-react/src/components/Toast/__tests__/ToastBar.test.tsx index ede3a7026c..08c29d306c 100644 --- a/packages/web-react/src/components/Toast/__tests__/ToastBar.test.tsx +++ b/packages/web-react/src/components/Toast/__tests__/ToastBar.test.tsx @@ -1,10 +1,10 @@ import '@testing-library/jest-dom'; import { render, screen } from '@testing-library/react'; import React from 'react'; -import { useIconMock, classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; +import { classNamePrefixProviderTest, restPropsTest, stylePropsTest } from '@local/tests'; import ToastBar from '../ToastBar'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('ToastBar', () => { classNamePrefixProviderTest((props) => , 'ToastBar'); diff --git a/packages/web-react/src/components/Toast/__tests__/UncontrolledToast.test.tsx b/packages/web-react/src/components/Toast/__tests__/UncontrolledToast.test.tsx index 95d9dac81b..69042650f1 100644 --- a/packages/web-react/src/components/Toast/__tests__/UncontrolledToast.test.tsx +++ b/packages/web-react/src/components/Toast/__tests__/UncontrolledToast.test.tsx @@ -1,12 +1,11 @@ import '@testing-library/jest-dom'; import { render } from '@testing-library/react'; import React from 'react'; -import { useIconMock } from '@local/tests'; import { ToastLinkProps } from '../../../types'; import { ToastContext } from '../ToastContext'; import UncontrolledToast from '../UncontrolledToast'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); const defaultToast = { id: 'test-id', diff --git a/packages/web-react/src/components/UNSTABLE_Avatar/__tests__/UNSTABLE_Avatar.test.tsx b/packages/web-react/src/components/UNSTABLE_Avatar/__tests__/UNSTABLE_Avatar.test.tsx index eae0530fb0..68b1210fb7 100644 --- a/packages/web-react/src/components/UNSTABLE_Avatar/__tests__/UNSTABLE_Avatar.test.tsx +++ b/packages/web-react/src/components/UNSTABLE_Avatar/__tests__/UNSTABLE_Avatar.test.tsx @@ -1,17 +1,11 @@ import '@testing-library/jest-dom'; import { render, screen } from '@testing-library/react'; import React from 'react'; -import { - useIconMock, - classNamePrefixProviderTest, - sizeExtendedPropsTest, - restPropsTest, - stylePropsTest, -} from '@local/tests'; +import { classNamePrefixProviderTest, sizeExtendedPropsTest, restPropsTest, stylePropsTest } from '@local/tests'; import { Icon } from '../../Icon'; import UNSTABLE_Avatar from '../UNSTABLE_Avatar'; -jest.mock('../../../hooks', () => useIconMock); +jest.mock('../../../hooks/useIcon'); describe('UNSTABLE_Avatar', () => { classNamePrefixProviderTest(UNSTABLE_Avatar, 'UNSTABLE_Avatar'); diff --git a/packages/web-react/src/hooks/__mocks__/useIcon.ts b/packages/web-react/src/hooks/__mocks__/useIcon.ts new file mode 100644 index 0000000000..b902a76c36 --- /dev/null +++ b/packages/web-react/src/hooks/__mocks__/useIcon.ts @@ -0,0 +1 @@ +export const useIcon = jest.fn(() => ''); diff --git a/packages/web-react/tests/index.ts b/packages/web-react/tests/index.ts index 552eb05607..d0c2bf68b4 100644 --- a/packages/web-react/tests/index.ts +++ b/packages/web-react/tests/index.ts @@ -1,3 +1,2 @@ export * from './providerTests'; export * from './testUtils'; -export * from './mocks'; diff --git a/packages/web-react/tests/mocks/hooksMock.ts b/packages/web-react/tests/mocks/hooksMock.ts deleted file mode 100644 index e32d8bb842..0000000000 --- a/packages/web-react/tests/mocks/hooksMock.ts +++ /dev/null @@ -1,4 +0,0 @@ -export const useIconMock = { - ...jest.requireActual('../../src/hooks'), - useIcon: () => '', -}; diff --git a/packages/web-react/tests/mocks/index.ts b/packages/web-react/tests/mocks/index.ts deleted file mode 100644 index d5ff221b08..0000000000 --- a/packages/web-react/tests/mocks/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './hooksMock';