@openmrs/esm-framework 3.1.15-pre.751 → 3.1.15-pre.759
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 +72 -101
- 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,23 +174,44 @@ 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
|
|
|
194
|
+
/* esm-extensions */
|
|
195
|
+
|
|
196
|
+
export const attach = jest.fn();
|
|
197
|
+
export const detach = jest.fn();
|
|
198
|
+
export const detachAll = jest.fn();
|
|
199
|
+
|
|
148
200
|
export const switchTo = jest.fn();
|
|
149
201
|
|
|
150
|
-
export const
|
|
202
|
+
export const ExtensionSlot = ({ children }) => <>{children}</>;
|
|
151
203
|
|
|
152
|
-
export const
|
|
204
|
+
export const Extension = jest.fn().mockImplementation((props: any) => <slot />);
|
|
153
205
|
|
|
154
|
-
export const
|
|
155
|
-
|
|
156
|
-
|
|
206
|
+
export const extensionStore = getGlobalStore("extensions", { slots: {} });
|
|
207
|
+
|
|
208
|
+
/* esm-react-utils */
|
|
157
209
|
|
|
158
|
-
export const
|
|
210
|
+
export const ComponentContext = React.createContext(null);
|
|
211
|
+
|
|
212
|
+
export const openmrsComponentDecorator = jest
|
|
213
|
+
.fn()
|
|
214
|
+
.mockImplementation(() => (component) => component);
|
|
159
215
|
|
|
160
216
|
export const useCurrentPatient = jest.fn(() => [null, null, null, null]);
|
|
161
217
|
|
|
@@ -169,56 +225,6 @@ export const useExtensionSlot = jest.fn(() => ({
|
|
|
169
225
|
extensionIdsToRender: [],
|
|
170
226
|
}));
|
|
171
227
|
|
|
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();
|
|
189
|
-
|
|
190
|
-
export const fhirBaseUrl = "/ws/fhir2/R4";
|
|
191
|
-
|
|
192
|
-
export const ExtensionSlot = ({ children }) => <>{children}</>;
|
|
193
|
-
|
|
194
|
-
export const Extension = jest.fn().mockImplementation((props: any) => <slot />);
|
|
195
|
-
|
|
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
|
-
let state = { slots: {}, extensions: {} };
|
|
203
|
-
|
|
204
|
-
export const extensionStore = {
|
|
205
|
-
getState: () => state,
|
|
206
|
-
setState: (val) => {
|
|
207
|
-
state = { ...state, ...val };
|
|
208
|
-
},
|
|
209
|
-
subscribe: (updateFcn) => {
|
|
210
|
-
updateFcn(state);
|
|
211
|
-
return () => {};
|
|
212
|
-
},
|
|
213
|
-
unsubscribe: () => {},
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export const ComponentContext = React.createContext(null);
|
|
217
|
-
|
|
218
|
-
export const openmrsComponentDecorator = jest
|
|
219
|
-
.fn()
|
|
220
|
-
.mockImplementation(() => (component) => component);
|
|
221
|
-
|
|
222
228
|
export const UserHasAccess = jest.fn().mockImplementation((props: any) => {
|
|
223
229
|
return props.children;
|
|
224
230
|
});
|
|
@@ -238,21 +244,6 @@ export const useStore = (store: Store<any>, actions) => {
|
|
|
238
244
|
return { ...state, ...actions };
|
|
239
245
|
};
|
|
240
246
|
|
|
241
|
-
export const showNotification = jest.fn();
|
|
242
|
-
export const showToast = jest.fn();
|
|
243
|
-
|
|
244
|
-
export function setupPaths(config: any) {
|
|
245
|
-
window.openmrsBase = config.apiUrl;
|
|
246
|
-
window.spaBase = config.spaPath;
|
|
247
|
-
window.spaEnv = config.env || "production";
|
|
248
|
-
window.spaVersion = process.env.BUILD_VERSION;
|
|
249
|
-
window.getOpenmrsSpaBase = () => `${window.spaBase}/`;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
export const attach = jest.fn();
|
|
253
|
-
export const detach = jest.fn();
|
|
254
|
-
export const detachAll = jest.fn();
|
|
255
|
-
|
|
256
247
|
export const usePagination = jest.fn().mockImplementation(() => ({
|
|
257
248
|
currentPage: 1,
|
|
258
249
|
goTo: () => {},
|
|
@@ -261,27 +252,7 @@ export const usePagination = jest.fn().mockImplementation(() => ({
|
|
|
261
252
|
|
|
262
253
|
export const useVisitTypes = jest.fn(() => []);
|
|
263
254
|
|
|
264
|
-
|
|
265
|
-
if (!mode || mode == "standard") {
|
|
266
|
-
return dayjs(date).format("DD-MMM-YYYY");
|
|
267
|
-
}
|
|
268
|
-
if (mode == "wide") {
|
|
269
|
-
return dayjs(date).format("DD - MMM - YYYY");
|
|
270
|
-
}
|
|
271
|
-
if (mode == "no day") {
|
|
272
|
-
return dayjs(date).format("MMM YYYY");
|
|
273
|
-
}
|
|
274
|
-
if (mode == "no year") {
|
|
275
|
-
return dayjs(date).format("DD MMM");
|
|
276
|
-
}
|
|
277
|
-
console.warn("Unknown formatDate mode: ", mode);
|
|
278
|
-
return dayjs(date).format("DD-MMM-YYYY");
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
export const formatTime = jest.fn((date: Date) => {
|
|
282
|
-
return dayjs(date).format("HH:mm");
|
|
283
|
-
});
|
|
255
|
+
/* esm-styleguide */
|
|
284
256
|
|
|
285
|
-
export const
|
|
286
|
-
|
|
287
|
-
});
|
|
257
|
+
export const showNotification = jest.fn();
|
|
258
|
+
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.759",
|
|
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.759",
|
|
39
|
+
"@openmrs/esm-breadcrumbs": "^3.1.15-pre.759",
|
|
40
|
+
"@openmrs/esm-config": "^3.1.15-pre.759",
|
|
41
|
+
"@openmrs/esm-error-handling": "^3.1.15-pre.759",
|
|
42
|
+
"@openmrs/esm-extensions": "^3.1.15-pre.759",
|
|
43
|
+
"@openmrs/esm-globals": "^3.1.15-pre.759",
|
|
44
|
+
"@openmrs/esm-offline": "^3.1.15-pre.759",
|
|
45
|
+
"@openmrs/esm-react-utils": "^3.1.15-pre.759",
|
|
46
|
+
"@openmrs/esm-state": "^3.1.15-pre.759",
|
|
47
|
+
"@openmrs/esm-styleguide": "^3.1.15-pre.759",
|
|
48
|
+
"@openmrs/esm-utils": "^3.1.15-pre.759",
|
|
49
49
|
"dayjs": "^1.10.7"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "e1e595a6bffe08babf45116b5c0ebbd7950ee871"
|
|
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
|
+
});
|