@openmrs/esm-utils 4.0.3-pre.462 → 4.0.3
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/.turbo/turbo-build.log +2 -2
- package/package.json +2 -2
- package/src/omrs-dates.test.ts +17 -14
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[32m@openmrs/esm-utils:build[0m: cache hit, replaying output [
|
|
1
|
+
[32m@openmrs/esm-utils:build[0m: cache hit, replaying output [2mcfecd01c7d5a21a4[0m
|
|
2
2
|
[32m@openmrs/esm-utils:build: [0masset [1m[32mopenmrs-esm-utils.js[39m[22m 32.7 KiB [1m[32m[emitted][39m[22m [1m[32m[minimized][39m[22m (name: main) 1 related asset
|
|
3
3
|
[32m@openmrs/esm-utils:build: [0mruntime modules 2.02 KiB 7 modules
|
|
4
4
|
[32m@openmrs/esm-utils:build: [0morphan modules 22.6 KiB [1m[33m[orphan][39m[22m 5 modules
|
|
@@ -13,4 +13,4 @@
|
|
|
13
13
|
[32m@openmrs/esm-utils:build: [0m[1m./src/index.ts + 5 modules[39m[22m 22.7 KiB [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
14
14
|
[32m@openmrs/esm-utils:build: [0m[1mexternal "dayjs"[39m[22m 42 bytes [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
15
15
|
[32m@openmrs/esm-utils:build: [0m[1mexternal "i18next"[39m[22m 42 bytes [1m[33m[built][39m[22m [1m[33m[code generated][39m[22m
|
|
16
|
-
[32m@openmrs/esm-utils:build: [0mwebpack 5.74.0 compiled [1m[32msuccessfully[39m[22m in
|
|
16
|
+
[32m@openmrs/esm-utils:build: [0mwebpack 5.74.0 compiled [1m[32msuccessfully[39m[22m in 11921 ms
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-utils",
|
|
3
|
-
"version": "4.0.3
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Helper utilities for OpenMRS",
|
|
6
6
|
"browser": "dist/openmrs-esm-utils.js",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"semver": "7.3.2"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "e18b3d46fd3ff3554957458129b8bf8470349052"
|
|
53
53
|
}
|
package/src/omrs-dates.test.ts
CHANGED
|
@@ -32,6 +32,7 @@ describe("Openmrs Dates", () => {
|
|
|
32
32
|
expect(isOmrsDateStrict(null as any)).toEqual(false);
|
|
33
33
|
expect(isOmrsDateStrict(undefined as any)).toEqual(false);
|
|
34
34
|
});
|
|
35
|
+
|
|
35
36
|
it("converts omrs date string version to js Date object", () => {
|
|
36
37
|
expect(
|
|
37
38
|
toDateObjectStrict("2018-03-19T00:00:00.000+0300")?.toUTCString()
|
|
@@ -52,10 +53,10 @@ describe("Openmrs Dates", () => {
|
|
|
52
53
|
testDate.setHours(15);
|
|
53
54
|
testDate.setMinutes(22);
|
|
54
55
|
window.i18next.language = "en";
|
|
55
|
-
expect(formatDate(testDate)).
|
|
56
|
-
expect(formatDate(testDate, { day: false })).
|
|
57
|
-
expect(formatDate(testDate, { year: false })).
|
|
58
|
-
expect(formatDate(testDate, { mode: "wide" })).
|
|
56
|
+
expect(formatDate(testDate)).toMatch(/Today,\s+03:22\sPM/);
|
|
57
|
+
expect(formatDate(testDate, { day: false })).toMatch(/Today,\s03:22\sPM/);
|
|
58
|
+
expect(formatDate(testDate, { year: false })).toMatch(/Today,\s03:22\sPM/);
|
|
59
|
+
expect(formatDate(testDate, { mode: "wide" })).toMatch(/Today,\s03:22\sPM/);
|
|
59
60
|
window.i18next.language = "sw";
|
|
60
61
|
expect(formatDate(testDate)).toEqual("Leo, 15:22");
|
|
61
62
|
window.i18next.language = "ru";
|
|
@@ -81,8 +82,8 @@ describe("Openmrs Dates", () => {
|
|
|
81
82
|
window.i18next.language = "sw";
|
|
82
83
|
expect(formatDate(testDate)).toEqual("09 Des 2021");
|
|
83
84
|
window.i18next.language = "ru";
|
|
84
|
-
expect(formatDate(testDate, { mode: "wide" })).
|
|
85
|
-
|
|
85
|
+
expect(formatDate(testDate, { mode: "wide" })).toMatch(
|
|
86
|
+
/09\s—\sдек\.\s—\s2021\sг\./
|
|
86
87
|
);
|
|
87
88
|
});
|
|
88
89
|
|
|
@@ -94,23 +95,25 @@ describe("Openmrs Dates", () => {
|
|
|
94
95
|
today.setMinutes(22);
|
|
95
96
|
window.i18next.language = "en";
|
|
96
97
|
expect(formatDate(testDate)).toEqual("09-Dec-2021");
|
|
97
|
-
expect(formatDate(testDate, { time: true })).
|
|
98
|
-
|
|
98
|
+
expect(formatDate(testDate, { time: true })).toMatch(
|
|
99
|
+
/09-Dec-2021,\s01:15\sPM/
|
|
99
100
|
);
|
|
100
101
|
expect(formatDate(testDate, { time: false })).toEqual("09-Dec-2021");
|
|
101
102
|
expect(formatDate(testDate, { time: "for today" })).toEqual("09-Dec-2021");
|
|
102
|
-
expect(formatDate(today, { time: true })).
|
|
103
|
+
expect(formatDate(today, { time: true })).toMatch(/Today,\s03:22\sPM/);
|
|
103
104
|
expect(formatDate(today, { time: false })).toEqual("Today");
|
|
104
|
-
expect(formatDate(today, { time: "for today" })).
|
|
105
|
+
expect(formatDate(today, { time: "for today" })).toMatch(
|
|
106
|
+
/Today, 03:22\sPM/
|
|
107
|
+
);
|
|
105
108
|
});
|
|
106
109
|
|
|
107
110
|
it("formats times with respect to the locale", () => {
|
|
108
111
|
timezoneMock.register("Australia/Adelaide");
|
|
109
112
|
const testDate = new Date("2021-12-09T13:15:33");
|
|
110
113
|
window.i18next.language = "en";
|
|
111
|
-
expect(formatTime(testDate)).
|
|
114
|
+
expect(formatTime(testDate)).toMatch(/01:15\sPM/i);
|
|
112
115
|
window.i18next.language = "es-CO";
|
|
113
|
-
expect(formatTime(testDate)).toMatch(/1:15
|
|
116
|
+
expect(formatTime(testDate)).toMatch(/1:15\sp.\sm./); // it's not a normal space between the 'p.' and 'm.'
|
|
114
117
|
window.i18next.language = "es-MX";
|
|
115
118
|
expect(formatTime(testDate)).toEqual("13:15");
|
|
116
119
|
});
|
|
@@ -122,8 +125,8 @@ describe("Openmrs Dates", () => {
|
|
|
122
125
|
todayDate.setHours(15);
|
|
123
126
|
todayDate.setMinutes(20);
|
|
124
127
|
window.i18next.language = "en";
|
|
125
|
-
expect(formatDatetime(testDate)).
|
|
126
|
-
expect(formatDatetime(todayDate)).
|
|
128
|
+
expect(formatDatetime(testDate)).toMatch(/09-Feb-2022,\s01:15\sPM/i);
|
|
129
|
+
expect(formatDatetime(todayDate)).toMatch(/Today,\s03:20\sPM/i);
|
|
127
130
|
window.i18next.language = "ht";
|
|
128
131
|
expect(formatDatetime(testDate)).toEqual("09 févr. 2022, 13:15");
|
|
129
132
|
expect(formatDatetime(todayDate)).toEqual("Aujourd’hui, 15:20");
|