From: Jérôme Benoit Date: Sun, 11 Dec 2022 20:40:56 +0000 (+0100) Subject: Apply dependencies update X-Git-Tag: v1.1.89~75 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d439da5cfbb01ef12fcf9a46150715d91bf06c81;p=e-mobility-charging-stations-simulator.git Apply dependencies update Signed-off-by: Jérôme Benoit --- diff --git a/package-lock.json b/package-lock.json index 237fd74b..7fde64e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -38,7 +38,7 @@ "@rollup/plugin-json": "^5.0.2", "@types/mocha": "^10.0.1", "@types/mochawesome": "^6.2.1", - "@types/node": "^18.11.12", + "@types/node": "^18.11.13", "@types/proper-lockfile": "^4.1.2", "@types/tar": "^6.1.3", "@types/ws": "^8.5.3", @@ -58,12 +58,12 @@ "expect": "^29.3.1", "husky": "^8.0.2", "lint-staged": "^13.1.0", - "mocha": "^10.1.0", + "mocha": "^10.2.0", "mochawesome": "^7.1.3", "prettier": "^2.8.1", "release-it": "^15.5.1", "robohydra": "^0.6.9", - "rollup": "^3.7.0", + "rollup": "^3.7.3", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-copy": "^3.4.0", "rollup-plugin-delete": "^2.0.0", @@ -2531,9 +2531,9 @@ } }, "node_modules/@types/node": { - "version": "18.11.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.12.tgz", - "integrity": "sha512-FgD3NtTAKvyMmD44T07zz2fEf+OKwutgBCEVM8GcvMGVGaDktiLNTDvPwC/LUe3PinMW+X6CuLOF2Ui1mAlSXg==" + "version": "18.11.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.13.tgz", + "integrity": "sha512-IASpMGVcWpUsx5xBOrxMj7Bl8lqfuTY7FKAnPmu5cHkfQVWF8GulWS1jbRqA934qZL35xh5xN/+Xe/i26Bod4w==" }, "node_modules/@types/object-path": { "version": "0.11.1", @@ -10665,9 +10665,9 @@ } }, "node_modules/mocha": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", - "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", "dev": true, "dependencies": { "ansi-colors": "4.1.1", @@ -14323,9 +14323,9 @@ } }, "node_modules/rollup": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.7.0.tgz", - "integrity": "sha512-FIJe0msW9P7L9BTfvaJyvn1U1BVCNTL3w8O+PKIrCyiMLg+rIUGb4MbcgVZ10Lnm1uWXOTOWRNARjfXC1+M12Q==", + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.7.3.tgz", + "integrity": "sha512-7e68MQbAWCX6mI4/0lG1WHd+NdNAlVamg0Zkd+8LZ/oXojligdGnCNyHlzXqXCZObyjs5FRc3AH0b17iJESGIQ==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -19432,9 +19432,9 @@ } }, "@types/node": { - "version": "18.11.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.12.tgz", - "integrity": "sha512-FgD3NtTAKvyMmD44T07zz2fEf+OKwutgBCEVM8GcvMGVGaDktiLNTDvPwC/LUe3PinMW+X6CuLOF2Ui1mAlSXg==" + "version": "18.11.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.13.tgz", + "integrity": "sha512-IASpMGVcWpUsx5xBOrxMj7Bl8lqfuTY7FKAnPmu5cHkfQVWF8GulWS1jbRqA934qZL35xh5xN/+Xe/i26Bod4w==" }, "@types/object-path": { "version": "0.11.1", @@ -25839,9 +25839,9 @@ } }, "mocha": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.1.0.tgz", - "integrity": "sha512-vUF7IYxEoN7XhQpFLxQAEMtE4W91acW4B6En9l97MwE9stL1A9gusXfoHZCLVHDUJ/7V5+lbCM6yMqzo5vNymg==", + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", + "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", "dev": true, "requires": { "ansi-colors": "4.1.1", @@ -28553,9 +28553,9 @@ } }, "rollup": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.7.0.tgz", - "integrity": "sha512-FIJe0msW9P7L9BTfvaJyvn1U1BVCNTL3w8O+PKIrCyiMLg+rIUGb4MbcgVZ10Lnm1uWXOTOWRNARjfXC1+M12Q==", + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.7.3.tgz", + "integrity": "sha512-7e68MQbAWCX6mI4/0lG1WHd+NdNAlVamg0Zkd+8LZ/oXojligdGnCNyHlzXqXCZObyjs5FRc3AH0b17iJESGIQ==", "dev": true, "requires": { "fsevents": "~2.3.2" diff --git a/package.json b/package.json index 5d0c2dcf..6c47903c 100644 --- a/package.json +++ b/package.json @@ -105,7 +105,7 @@ "@rollup/plugin-json": "^5.0.2", "@types/mocha": "^10.0.1", "@types/mochawesome": "^6.2.1", - "@types/node": "^18.11.12", + "@types/node": "^18.11.13", "@types/proper-lockfile": "^4.1.2", "@types/tar": "^6.1.3", "@types/ws": "^8.5.3", @@ -125,12 +125,12 @@ "expect": "^29.3.1", "husky": "^8.0.2", "lint-staged": "^13.1.0", - "mocha": "^10.1.0", + "mocha": "^10.2.0", "mochawesome": "^7.1.3", "prettier": "^2.8.1", "release-it": "^15.5.1", "robohydra": "^0.6.9", - "rollup": "^3.7.0", + "rollup": "^3.7.3", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-copy": "^3.4.0", "rollup-plugin-delete": "^2.0.0", diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 8c13db91..f1893531 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -401,7 +401,7 @@ export default class Configuration { } } - private static isObject(item): boolean { + private static isObject(item: unknown): boolean { return item && typeof item === 'object' && Array.isArray(item) === false; } diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 8dda95a6..006e9ddd 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -50,16 +50,17 @@ export default class Utils { return Utils.formatDurationMilliSeconds(duration * 1000); } - public static convertToDate(value: unknown): Date { - // Check - if (!value) { - return value as Date; + public static convertToDate(value: unknown): Date | null | undefined { + if (Utils.isNullOrUndefined(value)) { + return value as null | undefined; + } + if (value instanceof Date) { + return value; } - // Check Type - if (!(value instanceof Date)) { - return new Date(value as string); + if (Utils.isString(value) || typeof value === 'number') { + return new Date(value as string | number); } - return value; + return null; } public static convertToInt(value: unknown): number { diff --git a/test/utils/UtilsTest.ts b/test/utils/UtilsTest.ts index 36d06ddb..8093d5e7 100644 --- a/test/utils/UtilsTest.ts +++ b/test/utils/UtilsTest.ts @@ -25,26 +25,22 @@ describe('Utils test suite', () => { it('Verify convertToDate()', () => { expect(Utils.convertToDate(undefined)).toBe(undefined); expect(Utils.convertToDate(null)).toBe(null); - expect(Utils.convertToDate(0)).toBe(0); + const invalidDate = Utils.convertToDate(''); + expect(invalidDate instanceof Date && !isNaN(invalidDate.getTime())).toBe(false); + expect(Utils.convertToDate(0)).toStrictEqual(new Date('1970-01-01T00:00:00.000Z')); + expect(Utils.convertToDate([])).toBe(null); + expect(Utils.convertToDate({})).toBe(null); + expect(Utils.convertToDate(new Map())).toBe(null); + expect(Utils.convertToDate(new Set())).toBe(null); + expect(Utils.convertToDate(new WeakMap())).toBe(null); + expect(Utils.convertToDate(new WeakSet())).toBe(null); const dateStr = '2020-01-01T00:00:00.000Z'; let date = Utils.convertToDate(dateStr); expect(date).toBeInstanceOf(Date); - expect(date.getUTCFullYear()).toBe(2020); - expect(date.getUTCMonth()).toBe(0); - expect(date.getUTCDate()).toBe(1); - expect(date.getUTCHours()).toBe(0); - expect(date.getUTCMinutes()).toBe(0); - expect(date.getUTCSeconds()).toBe(0); - expect(date.getUTCMilliseconds()).toBe(0); + expect(date).toStrictEqual(new Date(dateStr)); date = Utils.convertToDate(new Date(dateStr)); expect(date).toBeInstanceOf(Date); - expect(date.getUTCFullYear()).toBe(2020); - expect(date.getUTCMonth()).toBe(0); - expect(date.getUTCDate()).toBe(1); - expect(date.getUTCHours()).toBe(0); - expect(date.getUTCMinutes()).toBe(0); - expect(date.getUTCSeconds()).toBe(0); - expect(date.getUTCMilliseconds()).toBe(0); + expect(date).toStrictEqual(new Date(dateStr)); }); it('Verify convertToInt()', () => { diff --git a/ui/web/package-lock.json b/ui/web/package-lock.json index b7c038f0..a8895268 100644 --- a/ui/web/package-lock.json +++ b/ui/web/package-lock.json @@ -18,7 +18,7 @@ "devDependencies": { "@types/chai": "^4.3.4", "@types/mocha": "^10.0.1", - "@types/node": "^18.11.12", + "@types/node": "^18.11.13", "@typescript-eslint/eslint-plugin": "^5.46.0", "@typescript-eslint/parser": "^5.46.0", "@vue/cli": "~5.0.8", @@ -2863,9 +2863,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.11.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.12.tgz", - "integrity": "sha512-FgD3NtTAKvyMmD44T07zz2fEf+OKwutgBCEVM8GcvMGVGaDktiLNTDvPwC/LUe3PinMW+X6CuLOF2Ui1mAlSXg==", + "version": "18.11.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.13.tgz", + "integrity": "sha512-IASpMGVcWpUsx5xBOrxMj7Bl8lqfuTY7FKAnPmu5cHkfQVWF8GulWS1jbRqA934qZL35xh5xN/+Xe/i26Bod4w==", "dev": true }, "node_modules/@types/normalize-package-data": { @@ -13912,9 +13912,9 @@ } }, "node_modules/postcss": { - "version": "8.4.19", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.19.tgz", - "integrity": "sha512-h+pbPsyhlYj6N2ozBmHhHrs9DzGmbaarbLvWipMRO7RLS+v4onj26MPFXA5OBYFxyqYhUJK456SwDcY9H2/zsA==", + "version": "8.4.20", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.20.tgz", + "integrity": "sha512-6Q04AXR1212bXr5fh03u8aAwbLxAQNGQ/Q1LNa0VfOI06ZAlhPHtQvE4OIdpj4kLThXilalPnmDSOD65DcHt+g==", "funding": [ { "type": "opencollective", @@ -20864,9 +20864,9 @@ "dev": true }, "@types/node": { - "version": "18.11.12", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.12.tgz", - "integrity": "sha512-FgD3NtTAKvyMmD44T07zz2fEf+OKwutgBCEVM8GcvMGVGaDktiLNTDvPwC/LUe3PinMW+X6CuLOF2Ui1mAlSXg==", + "version": "18.11.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.13.tgz", + "integrity": "sha512-IASpMGVcWpUsx5xBOrxMj7Bl8lqfuTY7FKAnPmu5cHkfQVWF8GulWS1jbRqA934qZL35xh5xN/+Xe/i26Bod4w==", "dev": true }, "@types/normalize-package-data": { @@ -29248,9 +29248,9 @@ "dev": true }, "postcss": { - "version": "8.4.19", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.19.tgz", - "integrity": "sha512-h+pbPsyhlYj6N2ozBmHhHrs9DzGmbaarbLvWipMRO7RLS+v4onj26MPFXA5OBYFxyqYhUJK456SwDcY9H2/zsA==", + "version": "8.4.20", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.20.tgz", + "integrity": "sha512-6Q04AXR1212bXr5fh03u8aAwbLxAQNGQ/Q1LNa0VfOI06ZAlhPHtQvE4OIdpj4kLThXilalPnmDSOD65DcHt+g==", "requires": { "nanoid": "^3.3.4", "picocolors": "^1.0.0", diff --git a/ui/web/package.json b/ui/web/package.json index dd5426a0..702e871d 100644 --- a/ui/web/package.json +++ b/ui/web/package.json @@ -21,7 +21,7 @@ "devDependencies": { "@types/chai": "^4.3.4", "@types/mocha": "^10.0.1", - "@types/node": "^18.11.12", + "@types/node": "^18.11.13", "@typescript-eslint/eslint-plugin": "^5.46.0", "@typescript-eslint/parser": "^5.46.0", "@vue/cli": "~5.0.8",