diff --git a/jest.config.ts b/jest.config.ts index 1d800abd36..70e4631bb9 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -18,6 +18,7 @@ const config: Config = { ...pathsToModuleNameMapper(compilerOptions.paths, { prefix: '/src', }), + '^papi-components$': '/node_modules/papi-components/dist/index.es.js', }, testEnvironment: 'jsdom', testEnvironmentOptions: { diff --git a/src/__tests__/app.component.test.tsx b/src/__tests__/app.component.test.tsx index f309601db9..115524d6fa 100644 --- a/src/__tests__/app.component.test.tsx +++ b/src/__tests__/app.component.test.tsx @@ -39,19 +39,6 @@ jest.mock('@renderer/components/docking/platform-dock-layout.component', () => ( __esModule: true, default: /** ParanextDockLayout Mock */ () => undefined, })); -// Mock all of the papi-components because they should test themselves -jest.mock( - 'papi-components', - () => - new Proxy( - {}, - { - get() { - return function MockComponent() {}; - }, - }, - ), -); describe('App', () => { it('should render', async () => { diff --git a/src/__tests__/button.component.test.tsx b/src/__tests__/button.component.test.tsx new file mode 100644 index 0000000000..0eb06071d2 --- /dev/null +++ b/src/__tests__/button.component.test.tsx @@ -0,0 +1,20 @@ +import { render, fireEvent } from '@testing-library/react'; +import { Button } from 'papi-components'; +import '@testing-library/jest-dom/extend-expect'; + +describe('Button', () => { + it('renders button text correctly', () => { + const buttonText = 'Click me'; + const { getByText } = render(); + expect(getByText(buttonText)).toBeInTheDocument(); + }); + + it('handles click event correctly', () => { + const handleClick = jest.fn(); + const { getByText } = render(); + + fireEvent.click(getByText('Click me')); + + expect(handleClick).toHaveBeenCalledTimes(1); + }); +}); diff --git a/src/renderer/components/docking/platform-dock-layout.component.test.ts b/src/renderer/components/docking/platform-dock-layout.component.test.ts index caebc0310b..b430cf0394 100644 --- a/src/renderer/components/docking/platform-dock-layout.component.test.ts +++ b/src/renderer/components/docking/platform-dock-layout.component.test.ts @@ -1,18 +1,5 @@ /* eslint-disable import/first */ jest.mock('../../../shared/services/logger.service'); -// Mock all of the papi-components because they should test themselves -jest.mock( - 'papi-components', - () => - new Proxy( - {}, - { - get() { - return function MockComponent() {}; - }, - }, - ), -); import DockLayout, { FloatPosition } from 'rc-dock'; import { anything, instance, mock, verify, when } from 'ts-mockito';