Skip to content

Commit

Permalink
(test) Add stubs for PageHeader and PageHeaderContent to framework mock
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen committed Aug 24, 2024
1 parent 14869ce commit 4a8326d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import React from 'react';
import { of } from 'rxjs';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { useConfig, useConnectedExtensions, useSession } from '@openmrs/esm-framework';
import { isDesktop } from './utils';
import { mockUser } from '../__mocks__/mock-user';
import { mockSession } from '../__mocks__/mock-session';
import Root from './root.component';
import { useConfig, useConnectedExtensions, useSession } from '@openmrs/esm-framework';

const mockUserObservable = of(mockUser);
const mockSessionObservable = of({ data: mockSession });
const mockIsDesktop = jest.mocked(isDesktop);

const mockedUseConfig = useConfig as jest.Mock;
const mockedUseConnectedExtensions = useConnectedExtensions as jest.Mock;
Expand Down Expand Up @@ -55,7 +56,7 @@ describe('Root', () => {

describe('when view is desktop', () => {
beforeEach(() => {
(isDesktop as jest.Mock).mockImplementation(() => true);
mockIsDesktop.mockImplementation(() => true);
});

it('does not render side menu button if desktop', async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/framework/esm-styleguide/mock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export const LaboratoryPictogram = () => <div>LaboratoryPictogramPictogram</div>
export const PatientListsPictogram = () => <div>PatientListsPictogram</div>;
export const ServiceQueuesPictogram = () => <div>ServiceQueuesPictogramPictogram</div>;

export { PageHeader, PageHeaderContent } from './src/page-header/page-header.component';

export const LocationPicker = jest.fn(({ onChange, selectedLocationUuid }) => {
const locations = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/** @module @category UI */
import React from 'react';
import classNames from 'classnames';
import { useConfig } from '@openmrs/esm-react-utils';
import { type StyleguideConfigObject } from '../config-schema';
import styles from './page-header.module.scss';
import classNames from 'classnames';

export interface PageHeaderContentProps {
title: string | JSX.Element;
Expand Down

0 comments on commit 4a8326d

Please sign in to comment.