Skip to content

Commit

Permalink
fixup! Test(web-react): Mock usage of the useIcon hook
Browse files Browse the repository at this point in the history
  • Loading branch information
literat committed Dec 10, 2024
1 parent c5a25eb commit b1e1364
Show file tree
Hide file tree
Showing 29 changed files with 61 additions and 205 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import AccordionHeader from '../AccordionHeader';
import AccordionItem from '../AccordionItem';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('AccordionHeader', () => {
classNamePrefixProviderTest(AccordionHeader, 'Accordion__itemHeader');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
Expand All @@ -9,13 +10,7 @@ import AccordionContent from '../AccordionContent';
import AccordionHeader from '../AccordionHeader';
import AccordionItem from '../AccordionItem';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('AccordionItem', () => {
classNamePrefixProviderTest(AccordionItem, 'Accordion__item');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '@testing-library/jest-dom';
import { fireEvent, render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
Expand All @@ -9,13 +10,7 @@ import AccordionHeader from '../AccordionHeader';
import AccordionItem from '../AccordionItem';
import UncontrolledAccordion from '../UncontrolledAccordion';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('UncontrolledAccordion', () => {
classNamePrefixProviderTest(UncontrolledAccordion, 'Accordion');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { emotionColorPropsTest } from '../../../../tests/providerTests/dictionaryPropsTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import Alert from '../Alert';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('Alert', () => {
classNamePrefixProviderTest(Alert, 'Alert');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import Breadcrumbs from '../Breadcrumbs';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('Breadcrumbs', () => {
classNamePrefixProviderTest(Breadcrumbs, 'Breadcrumbs');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import BreadcrumbsItem from '../BreadcrumbsItem';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('BreadcrumbsItem', () => {
classNamePrefixProviderTest(BreadcrumbsItem, 'd-none');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import {
actionButtonColorPropsTest,
Expand All @@ -12,13 +13,7 @@ import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import Button from '../Button';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('Button', () => {
classNamePrefixProviderTest(Button, 'Button');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import {
actionButtonColorPropsTest,
Expand All @@ -12,13 +13,7 @@ import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import ButtonLink from '../ButtonLink';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('ButtonLink', () => {
classNamePrefixProviderTest(ButtonLink, 'Button');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import { Button } from '../../Button';
import DropdownTrigger from '../DropdownTrigger';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('DropdownTrigger', () => {
stylePropsTest((props) => <DropdownTrigger elementType={Button} {...props} />);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import '@testing-library/jest-dom';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import FileUploader from '../FileUploader';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('FileUploader', () => {
classNamePrefixProviderTest(FileUploader, 'FileUploader');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { render, screen } from '@testing-library/react';
import React from 'react';
import { renderToString } from 'react-dom/server';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { validationTextPropsTest } from '../../../../tests/providerTests/validationTextPropsTest';
import FileUploaderInput from '../FileUploaderInput';
import '@testing-library/jest-dom';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('FileUploaderInput', () => {
classNamePrefixProviderTest(FileUploaderInput, 'FileUploaderInput');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { SpiritFileUploaderAttachmentProps } from '../../../types';
import FileUploader from '../FileUploader';
import FileUploaderList from '../FileUploaderList';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('FileUploaderList', () => {
const props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import HeaderDialogCloseButton from '../HeaderDialogCloseButton';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('HeaderDialogCloseButton', () => {
classNamePrefixProviderTest(HeaderDialogCloseButton, 'HeaderDialogCloseButton');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import { HEADER_MENU_TOGGLE_LABEL_DEFAULT } from '../constants';
import HeaderMobileActions from '../HeaderMobileActions';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('HeaderMobileActions', () => {
classNamePrefixProviderTest(HeaderMobileActions, 'HeaderMobileActions');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import Icon from '../Icon';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('Icon', () => {
const AddIcon = (props: Record<string, unknown>) => <Icon {...props} name="add" data-testid="test-icon" />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import '@testing-library/jest-dom';
import { render } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import { SpiritItemProps } from '../../../types';
import Item from '../Item';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('Item', () => {
stylePropsTest(Item);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import '@testing-library/jest-dom';
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import ModalCloseButton from '../ModalCloseButton';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('ModalCloseButton', () => {
classNamePrefixProviderTest(ModalCloseButton, 'Button');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import React from 'react';
import { useIconMock } from '../../../../tests/mocks/hooksMock';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import ModalHeader from '../ModalHeader';

jest.mock('../../../hooks', () => {
return {
...jest.requireActual('../../../hooks'),
// eslint-disable-next-line @typescript-eslint/no-unused-vars
useIcon: (name: string) => '',
};
});
jest.mock('../../../hooks', () => useIconMock);

describe('ModalHeader', () => {
classNamePrefixProviderTest(ModalHeader, 'ModalHeader');
Expand Down
Loading

0 comments on commit b1e1364

Please sign in to comment.