]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commitdiff
fix: correct @mikro-orm/sqlite import to @mikro-orm/better-sqlite, format ElectricUti...
authorJérôme Benoit <jerome.benoit@sap.com>
Fri, 6 Mar 2026 22:40:36 +0000 (23:40 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Fri, 6 Mar 2026 22:40:36 +0000 (23:40 +0100)
mikro-orm.config.ts [new file with mode: 0644]
tests/utils/ElectricUtils.test.ts

diff --git a/mikro-orm.config.ts b/mikro-orm.config.ts
new file mode 100644 (file)
index 0000000..db186aa
--- /dev/null
@@ -0,0 +1,10 @@
+import { defineConfig } from '@mikro-orm/better-sqlite'
+
+import { Constants } from './src/utils/index.js'
+
+export default defineConfig({
+  dbName: `${Constants.DEFAULT_PERFORMANCE_DIRECTORY}/${Constants.DEFAULT_PERFORMANCE_RECORDS_DB_NAME}.db`,
+  debug: true,
+  entities: ['./dist/types/orm/entities/*.js'],
+  entitiesTs: ['./src/types/orm/entities/*.ts'],
+})
index 997861628e748dfad899491134140d61b0f60108..a9cd9ac4e12b64f79be05fcd789908ffa41f6e19 100644 (file)
@@ -16,53 +16,65 @@ await describe('ElectricUtils', async () => {
   afterEach(() => {
     standardCleanup()
   })
+
   await it('should calculate DC power from voltage and current', () => {
     expect(DCElectricUtils.power(230, 1)).toBe(230)
   })
+
   await it('should calculate DC amperage from power and voltage', () => {
     expect(DCElectricUtils.amperage(1, 230)).toBe(0)
   })
+
   await it('should calculate total AC power for all phases', () => {
     expect(ACElectricUtils.powerTotal(3, 230, 1)).toBe(690)
   })
+
   await it('should calculate AC power per phase', () => {
     expect(ACElectricUtils.powerPerPhase(230, 1)).toBe(230)
   })
+
   await it('should calculate total AC amperage for all phases', () => {
     expect(ACElectricUtils.amperageTotal(3, 1)).toBe(3)
   })
+
   await it('should calculate total AC amperage from power and voltage', () => {
     expect(ACElectricUtils.amperageTotalFromPower(690, 230)).toBe(3)
   })
+
   await it('should calculate AC amperage per phase from power', () => {
     expect(ACElectricUtils.amperagePerPhaseFromPower(3, 690, 230)).toBe(1)
   })
+
   await it('should return 0 for DC amperage when voltage is zero', () => {
     expect(DCElectricUtils.amperage(1000, 0)).toBe(0)
   })
+
   await it('should return 0 for AC amperage when voltage is zero', () => {
     expect(ACElectricUtils.amperageTotalFromPower(1000, 0)).toBe(0)
   })
+
   await it('should return 0 for AC amperage when cosPhi is zero', () => {
     expect(ACElectricUtils.amperageTotalFromPower(1000, 230, 0)).toBe(0)
   })
+
   await it('should return 0 for AC amperage per phase when phases is zero or negative', () => {
     expect(ACElectricUtils.amperagePerPhaseFromPower(0, 690, 230)).toBe(0)
     expect(ACElectricUtils.amperagePerPhaseFromPower(-1, 690, 230)).toBe(0)
   })
+
   await it('should round AC power per phase with non-unity cosPhi', () => {
     expect(ACElectricUtils.powerPerPhase(230, 10, COS_PHI_RESIDENTIAL)).toBe(1955)
   })
+
   await it('should round DC amperage when power is not evenly divisible by voltage', () => {
     expect(DCElectricUtils.amperage(100, 3)).toBe(33)
   })
+
   await it('should calculate DC power as voltage times current', () => {
     expect(DCElectricUtils.power(0, 10)).toBe(0)
     expect(DCElectricUtils.power(400, 0)).toBe(0)
   })
 
-  // Realistic EV charging scenarios
-
   await it('should calculate 7.4 kW single-phase AC home charger values', () => {
     // 230V × 32A × 1 phase × cosPhi=1 = 7360W
     expect(ACElectricUtils.powerPerPhase(230, 32)).toBe(7360)