Skip to content

Commit

Permalink
(test) Add missing stubs to framework mock (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
denniskigen authored Aug 1, 2024
1 parent 665fd91 commit 6c99789
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
7 changes: 6 additions & 1 deletion packages/framework/esm-api/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const mockSessionStore = createGlobalStore<SessionStore>('mock-session-st
export const getSessionStore = jest.fn(() => mockSessionStore);
export const setCurrentVisit = jest.fn();
export const newWorkspaceItem = jest.fn();
export const restBaseURL = '/ws/rest/v1';
export const restBaseUrl = '/ws/rest/v1';
export const fhirBaseUrl = '/ws/fhir2/R4';
export const attachmentUrl = '/ws/rest/v1/attachment';
export const getAttachmentByUuid = jest.fn();
Expand All @@ -26,3 +26,8 @@ export const clearCurrentUser = jest.fn();
export const refetchCurrentUser = jest.fn();
export const setUserLanguage = jest.fn();
export const setUserProperties = jest.fn();
export const updateVisit = jest.fn();
export const saveVisit = jest.fn();
export const getVisitsForPatient = jest.fn();
export const getStartedVisit = jest.fn();
export const userHasAccess = jest.fn();
2 changes: 0 additions & 2 deletions packages/framework/esm-api/src/openmrs-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { clearHistory } from '@openmrs/esm-navigation/src/index';
import type { FetchResponse } from './types';

export const restBaseUrl = '/ws/rest/v1';

export const fhirBaseUrl = '/ws/fhir2/R4';

export const sessionEndpoint = `${restBaseUrl}/session`;

/**
Expand Down
10 changes: 5 additions & 5 deletions packages/framework/esm-framework/docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ ___

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:11](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L11)
[packages/framework/esm-api/src/openmrs-fetch.ts:10](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L10)

___

Expand Down Expand Up @@ -1002,7 +1002,7 @@ ___

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:13](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L13)
[packages/framework/esm-api/src/openmrs-fetch.ts:11](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L11)

___

Expand Down Expand Up @@ -2291,7 +2291,7 @@ makeUrl('/foo/bar');

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:25](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L25)
[packages/framework/esm-api/src/openmrs-fetch.ts:23](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L23)

___

Expand Down Expand Up @@ -2358,7 +2358,7 @@ free up memory and network resources and to prevent race conditions.
#### Defined in
[packages/framework/esm-api/src/openmrs-fetch.ts:85](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L85)
[packages/framework/esm-api/src/openmrs-fetch.ts:83](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L83)
___
Expand Down Expand Up @@ -2409,7 +2409,7 @@ To cancel the network request, simply call `subscription.unsubscribe();`

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:265](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L265)
[packages/framework/esm-api/src/openmrs-fetch.ts:263](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L263)

___

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Error.constructor

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:298](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L298)
[packages/framework/esm-api/src/openmrs-fetch.ts:296](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L296)

## API Properties

Expand All @@ -63,7 +63,7 @@ Error.constructor

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:306](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L306)
[packages/framework/esm-api/src/openmrs-fetch.ts:304](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L304)

___

Expand All @@ -73,7 +73,7 @@ ___

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:307](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L307)
[packages/framework/esm-api/src/openmrs-fetch.ts:305](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L305)

___

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:312](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L312)
[packages/framework/esm-api/src/openmrs-fetch.ts:310](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L310)

___

Expand All @@ -47,7 +47,7 @@ ___

#### Defined in

[packages/framework/esm-api/src/openmrs-fetch.ts:311](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L311)
[packages/framework/esm-api/src/openmrs-fetch.ts:309](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/openmrs-fetch.ts#L309)

___

Expand Down
8 changes: 8 additions & 0 deletions packages/framework/esm-react-utils/mock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,11 @@ export const useOnClickOutside = jest.fn();
export const useBodyScrollLock = jest.fn();

export const isDesktop = jest.fn().mockImplementation(realIsDesktop);

export const useLocations = jest.fn().mockReturnValue([]);

export const toOmrsIsoString = jest.fn().mockImplementation((date: Date) => date.toISOString());

export const toDateObjectStrict = jest.fn().mockImplementation((date: string) => new Date(date));

export const getLocale = jest.fn().mockReturnValue('en');

0 comments on commit 6c99789

Please sign in to comment.