forked from openmrs/openmrs-esm-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mock.ts
31 lines (23 loc) · 800 Bytes
/
mock.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { getGlobalStore } from '@openmrs/esm-state/mock';
export const attach = jest.fn();
export const detach = jest.fn();
export const detachAll = jest.fn();
export const switchTo = jest.fn();
export const getExtensionStore = () => getGlobalStore('extensions', { slots: {} });
export const getExtensionInternalStore = () =>
getGlobalStore('extensions-internal', {
slots: {},
extensions: {},
});
const mockExtensionRegistry = {};
export const getExtensionRegistration = jest.fn((name) => {
return mockExtensionRegistry[name];
});
export const registerExtension = jest.fn((ext) => {
mockExtensionRegistry[ext.name] = ext;
});
export function clearMockExtensionRegistry() {
Object.keys(mockExtensionRegistry).forEach((key) => {
delete mockExtensionRegistry[key];
});
}