@teamkeel/testing-runtime 0.404.1 → 0.405.1

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Executor.mjs +32 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamkeel/testing-runtime",
3
- "version": "0.404.1",
3
+ "version": "0.405.1",
4
4
  "description": "Internal package used by the generated @teamkeel/testing package",
5
5
  "exports": "./src/index.mjs",
6
6
  "typings": "src/index.d.ts",
package/src/Executor.mjs CHANGED
@@ -201,11 +201,40 @@ function isPlainObject(obj) {
201
201
  return Object.prototype.toString.call(obj) === "[object Object]";
202
202
  }
203
203
 
204
- const dateFormat = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:(\d{2}(?:\.\d*)?)Z$/;
204
+ const dateFormat =
205
+ /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)?$/;
205
206
 
206
207
  function reviver(key, value) {
207
- if (typeof value === "string" && dateFormat.test(value)) {
208
- return new Date(value);
208
+ // Handle date strings
209
+ if (typeof value === "string") {
210
+ if (dateFormat.test(value)) {
211
+ return new Date(value);
212
+ }
209
213
  }
214
+
215
+ // Handle nested objects
216
+ if (value !== null && typeof value === "object") {
217
+ // Handle arrays
218
+ if (Array.isArray(value)) {
219
+ return value.map((item) => {
220
+ if (typeof item === "string") {
221
+ if (dateFormat.test(item)) {
222
+ return new Date(item);
223
+ }
224
+ }
225
+ return item;
226
+ });
227
+ }
228
+
229
+ // Handle plain objects
230
+ for (const k in value) {
231
+ if (typeof value[k] === "string") {
232
+ if (dateFormat.test(value[k])) {
233
+ value[k] = new Date(value[k]);
234
+ }
235
+ }
236
+ }
237
+ }
238
+
210
239
  return value;
211
240
  }