test: add getPhaseRotationValue() test
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 31 Jul 2024 17:06:23 +0000 (19:06 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 31 Jul 2024 17:06:23 +0000 (19:06 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/charging-station/Helpers.test.ts

index 85e66adbbc5c05fac295919b7064f97969fe5cab..48c743b37463c8513d1f3affcbedcc9a49d99bb7 100644 (file)
@@ -10,6 +10,7 @@ import {
   getChargingStationId,
   getHashId,
   getMaxNumberOfEvses,
+  getPhaseRotationValue,
   validateStationInfo,
 } from '../../src/charging-station/Helpers.js'
 import type { ChargingStation } from '../../src/charging-station/index.js'
@@ -144,6 +145,21 @@ await describe('Helpers test suite', async () => {
     expect(logger.warn.mock.calls.length).toBe(1)
   })
 
+  await it('Verify getPhaseRotationValue()', () => {
+    expect(getPhaseRotationValue(0, 0)).toBe('0.RST')
+    expect(getPhaseRotationValue(1, 0)).toBe('1.NotApplicable')
+    expect(getPhaseRotationValue(2, 0)).toBe('2.NotApplicable')
+    expect(getPhaseRotationValue(0, 1)).toBe('0.NotApplicable')
+    expect(getPhaseRotationValue(1, 1)).toBe('1.NotApplicable')
+    expect(getPhaseRotationValue(2, 1)).toBe('2.NotApplicable')
+    expect(getPhaseRotationValue(0, 2)).toBeUndefined()
+    expect(getPhaseRotationValue(1, 2)).toBeUndefined()
+    expect(getPhaseRotationValue(2, 2)).toBeUndefined()
+    expect(getPhaseRotationValue(0, 3)).toBe('0.RST')
+    expect(getPhaseRotationValue(1, 3)).toBe('1.RST')
+    expect(getPhaseRotationValue(2, 3)).toBe('2.RST')
+  })
+
   await it('Verify getMaxNumberOfEvses()', () => {
     expect(getMaxNumberOfEvses(undefined)).toBe(-1)
     expect(getMaxNumberOfEvses({})).toBe(0)