@openmrs/esm-framework 3.1.15-pre.754 → 3.1.15-pre.757
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mocks__/fileMock.js +1 -0
- package/jest.config.js +2 -1
- package/mock.tsx +75 -92
- package/package.json +13 -13
- package/src/mock-test.test.ts +17 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = "test-file-stub";
|
package/jest.config.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
transform: {
|
|
3
|
-
"^.+\\.
|
|
3
|
+
"^.+\\.(j|t)sx?$": "babel-jest",
|
|
4
4
|
},
|
|
5
5
|
moduleNameMapper: {
|
|
6
6
|
"\\.(s?css)$": "identity-obj-proxy",
|
|
7
|
+
"\\.(svg)$": "<rootDir>/__mocks__/fileMock.js",
|
|
7
8
|
"lodash-es/(.*)": "lodash/$1",
|
|
8
9
|
},
|
|
9
10
|
setupFilesAfterEnv: ["<rootDir>/src/integration-tests/setup-tests.ts"],
|
package/mock.tsx
CHANGED
|
@@ -2,8 +2,48 @@ import React from "react";
|
|
|
2
2
|
import type {} from "@openmrs/esm-globals";
|
|
3
3
|
import createStore, { Store } from "unistore";
|
|
4
4
|
import { never, of } from "rxjs";
|
|
5
|
-
|
|
5
|
+
export {
|
|
6
|
+
parseDate,
|
|
7
|
+
formatDate,
|
|
8
|
+
formatDatetime,
|
|
9
|
+
formatTime,
|
|
10
|
+
} from "@openmrs/esm-utils";
|
|
6
11
|
|
|
12
|
+
window.i18next = { ...window.i18next, language: "en" };
|
|
13
|
+
|
|
14
|
+
/* esm-globals */
|
|
15
|
+
|
|
16
|
+
export function setupPaths(config: any) {
|
|
17
|
+
window.openmrsBase = config.apiUrl;
|
|
18
|
+
window.spaBase = config.spaPath;
|
|
19
|
+
window.spaEnv = config.env || "production";
|
|
20
|
+
window.spaVersion = process.env.BUILD_VERSION;
|
|
21
|
+
window.getOpenmrsSpaBase = () => `${window.spaBase}/`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* esm-utils */
|
|
25
|
+
export function isVersionSatisfied() {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* esm-api */
|
|
30
|
+
export const setSessionLocation = jest.fn(() => Promise.resolve());
|
|
31
|
+
|
|
32
|
+
export const openmrsFetch = jest.fn(() => new Promise(() => {}));
|
|
33
|
+
|
|
34
|
+
export const openmrsObservableFetch = jest.fn(() =>
|
|
35
|
+
of({ data: { entry: [] } })
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export function getCurrentUser() {
|
|
39
|
+
return of({ authenticated: false });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const newWorkspaceItem = jest.fn();
|
|
43
|
+
|
|
44
|
+
export const fhirBaseUrl = "/ws/fhir2/R4";
|
|
45
|
+
|
|
46
|
+
/* esm-state */
|
|
7
47
|
interface StoreEntity {
|
|
8
48
|
value: Store<any>;
|
|
9
49
|
active: boolean;
|
|
@@ -15,12 +55,6 @@ const initialStates: Record<string, any> = {};
|
|
|
15
55
|
|
|
16
56
|
const availableStores: Record<string, StoreEntity> = {};
|
|
17
57
|
|
|
18
|
-
export function isVersionSatisfied() {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const setSessionLocation = jest.fn(() => Promise.resolve());
|
|
23
|
-
|
|
24
58
|
export const mockStores = availableStores;
|
|
25
59
|
|
|
26
60
|
export function createGlobalStore<TState>(
|
|
@@ -83,6 +117,7 @@ function instrumentedStore<T>(name: string, store: Store<T>) {
|
|
|
83
117
|
} as any as MockedStore<T>;
|
|
84
118
|
}
|
|
85
119
|
|
|
120
|
+
/* esm-config */
|
|
86
121
|
export const configInternalStore = createGlobalStore("config-internal", {
|
|
87
122
|
devDefaultsAreOn: false,
|
|
88
123
|
});
|
|
@@ -139,66 +174,35 @@ export function defineConfigSchema(moduleName, schema) {
|
|
|
139
174
|
configSchema = schema;
|
|
140
175
|
}
|
|
141
176
|
|
|
177
|
+
export const navigate = jest.fn();
|
|
178
|
+
|
|
179
|
+
export const interpolateString = jest.fn();
|
|
180
|
+
|
|
181
|
+
export const ConfigurableLink = jest
|
|
182
|
+
.fn()
|
|
183
|
+
.mockImplementation((config: { to: string; children: React.ReactNode }) => (
|
|
184
|
+
<a href={interpolateString(config.to)}>{config.children}</a>
|
|
185
|
+
));
|
|
186
|
+
|
|
187
|
+
/* esm-error-handling */
|
|
142
188
|
export const createErrorHandler = () => jest.fn().mockReturnValue(never());
|
|
143
189
|
|
|
144
190
|
export const reportError = jest.fn().mockImplementation((error) => {
|
|
145
191
|
throw error;
|
|
146
192
|
});
|
|
147
193
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
export const UserHasAccessReact = (props: any) => props.children;
|
|
151
|
-
|
|
152
|
-
export const openmrsFetch = jest.fn(() => new Promise(() => {}));
|
|
153
|
-
|
|
154
|
-
export const openmrsObservableFetch = jest.fn(() =>
|
|
155
|
-
of({ data: { entry: [] } })
|
|
156
|
-
);
|
|
157
|
-
|
|
158
|
-
export const setIsUIEditorEnabled = (boolean): void => {};
|
|
159
|
-
|
|
160
|
-
export const useCurrentPatient = jest.fn(() => [null, null, null, null]);
|
|
194
|
+
/* esm-extensions */
|
|
161
195
|
|
|
162
|
-
export const
|
|
163
|
-
|
|
164
|
-
export const
|
|
165
|
-
|
|
166
|
-
export const useExtensionSlot = jest.fn(() => ({
|
|
167
|
-
extensionSlotModuleName: "",
|
|
168
|
-
attachedExtensionSlotName: "",
|
|
169
|
-
extensionIdsToRender: [],
|
|
170
|
-
}));
|
|
171
|
-
|
|
172
|
-
export const useExtension = jest.fn(() => [React.createRef(), undefined]);
|
|
173
|
-
|
|
174
|
-
export const getCurrentPatient = jest.fn(() =>
|
|
175
|
-
jest.fn().mockReturnValue(never())
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
export function getCurrentUser() {
|
|
179
|
-
return of({ authenticated: false });
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
export const navigate = jest.fn();
|
|
183
|
-
|
|
184
|
-
export const interpolateString = jest.fn();
|
|
185
|
-
|
|
186
|
-
export const getCurrentPatientUuid = jest.fn();
|
|
187
|
-
|
|
188
|
-
export const newWorkspaceItem = jest.fn();
|
|
196
|
+
export const attach = jest.fn();
|
|
197
|
+
export const detach = jest.fn();
|
|
198
|
+
export const detachAll = jest.fn();
|
|
189
199
|
|
|
190
|
-
export const
|
|
200
|
+
export const switchTo = jest.fn();
|
|
191
201
|
|
|
192
202
|
export const ExtensionSlot = ({ children }) => <>{children}</>;
|
|
193
203
|
|
|
194
204
|
export const Extension = jest.fn().mockImplementation((props: any) => <slot />);
|
|
195
205
|
|
|
196
|
-
export const ConfigurableLink = jest
|
|
197
|
-
.fn()
|
|
198
|
-
.mockImplementation((config: { to: string; children: React.ReactNode }) => (
|
|
199
|
-
<a href={interpolateString(config.to)}>{config.children}</a>
|
|
200
|
-
));
|
|
201
|
-
|
|
202
206
|
export const getExtensionStore = () =>
|
|
203
207
|
getGlobalStore("extensions", { slots: {} });
|
|
204
208
|
|
|
@@ -208,12 +212,26 @@ export const getExtensionInternalStore = () =>
|
|
|
208
212
|
extensions: {},
|
|
209
213
|
});
|
|
210
214
|
|
|
215
|
+
/* esm-react-utils */
|
|
216
|
+
|
|
211
217
|
export const ComponentContext = React.createContext(null);
|
|
212
218
|
|
|
213
219
|
export const openmrsComponentDecorator = jest
|
|
214
220
|
.fn()
|
|
215
221
|
.mockImplementation(() => (component) => component);
|
|
216
222
|
|
|
223
|
+
export const useCurrentPatient = jest.fn(() => [null, null, null, null]);
|
|
224
|
+
|
|
225
|
+
export const useSessionUser = jest.fn(() => null);
|
|
226
|
+
|
|
227
|
+
export const useLayoutType = jest.fn(() => "desktop");
|
|
228
|
+
|
|
229
|
+
export const useExtensionSlot = jest.fn(() => ({
|
|
230
|
+
extensionSlotModuleName: "",
|
|
231
|
+
attachedExtensionSlotName: "",
|
|
232
|
+
extensionIdsToRender: [],
|
|
233
|
+
}));
|
|
234
|
+
|
|
217
235
|
export const UserHasAccess = jest.fn().mockImplementation((props: any) => {
|
|
218
236
|
return props.children;
|
|
219
237
|
});
|
|
@@ -234,21 +252,6 @@ export const useStore = (store: Store<any>, actions) => {
|
|
|
234
252
|
return { ...state, ...actions };
|
|
235
253
|
};
|
|
236
254
|
|
|
237
|
-
export const showNotification = jest.fn();
|
|
238
|
-
export const showToast = jest.fn();
|
|
239
|
-
|
|
240
|
-
export function setupPaths(config: any) {
|
|
241
|
-
window.openmrsBase = config.apiUrl;
|
|
242
|
-
window.spaBase = config.spaPath;
|
|
243
|
-
window.spaEnv = config.env || "production";
|
|
244
|
-
window.spaVersion = process.env.BUILD_VERSION;
|
|
245
|
-
window.getOpenmrsSpaBase = () => `${window.spaBase}/`;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export const attach = jest.fn();
|
|
249
|
-
export const detach = jest.fn();
|
|
250
|
-
export const detachAll = jest.fn();
|
|
251
|
-
|
|
252
255
|
export const usePagination = jest.fn().mockImplementation(() => ({
|
|
253
256
|
currentPage: 1,
|
|
254
257
|
goTo: () => {},
|
|
@@ -257,27 +260,7 @@ export const usePagination = jest.fn().mockImplementation(() => ({
|
|
|
257
260
|
|
|
258
261
|
export const useVisitTypes = jest.fn(() => []);
|
|
259
262
|
|
|
260
|
-
|
|
261
|
-
if (!mode || mode == "standard") {
|
|
262
|
-
return dayjs(date).format("DD-MMM-YYYY");
|
|
263
|
-
}
|
|
264
|
-
if (mode == "wide") {
|
|
265
|
-
return dayjs(date).format("DD - MMM - YYYY");
|
|
266
|
-
}
|
|
267
|
-
if (mode == "no day") {
|
|
268
|
-
return dayjs(date).format("MMM YYYY");
|
|
269
|
-
}
|
|
270
|
-
if (mode == "no year") {
|
|
271
|
-
return dayjs(date).format("DD MMM");
|
|
272
|
-
}
|
|
273
|
-
console.warn("Unknown formatDate mode: ", mode);
|
|
274
|
-
return dayjs(date).format("DD-MMM-YYYY");
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
export const formatTime = jest.fn((date: Date) => {
|
|
278
|
-
return dayjs(date).format("HH:mm");
|
|
279
|
-
});
|
|
263
|
+
/* esm-styleguide */
|
|
280
264
|
|
|
281
|
-
export const
|
|
282
|
-
|
|
283
|
-
});
|
|
265
|
+
export const showNotification = jest.fn();
|
|
266
|
+
export const showToast = jest.fn();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-framework",
|
|
3
|
-
"version": "3.1.15-pre.
|
|
3
|
+
"version": "3.1.15-pre.757",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"browser": "dist/openmrs-esm-framework.js",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@openmrs/esm-api": "^3.1.15-pre.
|
|
39
|
-
"@openmrs/esm-breadcrumbs": "^3.1.15-pre.
|
|
40
|
-
"@openmrs/esm-config": "^3.1.15-pre.
|
|
41
|
-
"@openmrs/esm-error-handling": "^3.1.15-pre.
|
|
42
|
-
"@openmrs/esm-extensions": "^3.1.15-pre.
|
|
43
|
-
"@openmrs/esm-globals": "^3.1.15-pre.
|
|
44
|
-
"@openmrs/esm-offline": "^3.1.15-pre.
|
|
45
|
-
"@openmrs/esm-react-utils": "^3.1.15-pre.
|
|
46
|
-
"@openmrs/esm-state": "^3.1.15-pre.
|
|
47
|
-
"@openmrs/esm-styleguide": "^3.1.15-pre.
|
|
48
|
-
"@openmrs/esm-utils": "^3.1.15-pre.
|
|
38
|
+
"@openmrs/esm-api": "^3.1.15-pre.757",
|
|
39
|
+
"@openmrs/esm-breadcrumbs": "^3.1.15-pre.757",
|
|
40
|
+
"@openmrs/esm-config": "^3.1.15-pre.757",
|
|
41
|
+
"@openmrs/esm-error-handling": "^3.1.15-pre.757",
|
|
42
|
+
"@openmrs/esm-extensions": "^3.1.15-pre.757",
|
|
43
|
+
"@openmrs/esm-globals": "^3.1.15-pre.757",
|
|
44
|
+
"@openmrs/esm-offline": "^3.1.15-pre.757",
|
|
45
|
+
"@openmrs/esm-react-utils": "^3.1.15-pre.757",
|
|
46
|
+
"@openmrs/esm-state": "^3.1.15-pre.757",
|
|
47
|
+
"@openmrs/esm-styleguide": "^3.1.15-pre.757",
|
|
48
|
+
"@openmrs/esm-utils": "^3.1.15-pre.757",
|
|
49
49
|
"dayjs": "^1.10.7"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "9b005ddcbb5f1f0412081c7c85b5afbe4477b17e"
|
|
52
52
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A test that validates that `@openmrs/esm-framework/mock` has
|
|
3
|
+
* the same API as `@openmrs/esm-framework`.
|
|
4
|
+
*
|
|
5
|
+
* Disabled because the mock is nowhere close to having the same
|
|
6
|
+
* API. You can change `xit` to `it` to run the test and see a
|
|
7
|
+
* comparison of the exports of the two modules.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import * as real from "./index";
|
|
11
|
+
import * as mock from "../mock";
|
|
12
|
+
|
|
13
|
+
describe("@openmrs/esm-framework/mock", () => {
|
|
14
|
+
xit("should have the same exports as @openmrs/esm-framework", () => {
|
|
15
|
+
expect(new Set(Object.keys(real))).toEqual(new Set(Object.keys(mock)));
|
|
16
|
+
});
|
|
17
|
+
});
|