diff --git a/src/components/dashboards/scania/display/ScaniaDisplay.vue b/src/components/dashboards/scania/display/ScaniaDisplay.vue
index c3efae90..ea63642a 100644
--- a/src/components/dashboards/scania/display/ScaniaDisplay.vue
+++ b/src/components/dashboards/scania/display/ScaniaDisplay.vue
@@ -5,7 +5,7 @@
{{
- $trukShifterTypeLetter(
+ $truckShifterTypeLetter(
telemetry.truck.transmission,
telemetry.truck.brand
)
diff --git a/src/utils/telemetry/_grear.utils.js b/src/utils/telemetry/_grear.utils.js
index fbcbe0d5..05fc33b7 100644
--- a/src/utils/telemetry/_grear.utils.js
+++ b/src/utils/telemetry/_grear.utils.js
@@ -48,7 +48,7 @@ export const $trukGear = (transmission, brand, withShifterType = true) => {
return strGear;
};
-export const $trukShifterTypeLetter = (transmission, brand) => {
+export const $truckShifterTypeLetter = (transmission, brand) => {
const gear = $gearInfo(transmission, brand).gear;
const crawlingGear = $gearInfo(transmission, brand).crawlingGear;
let shifterType = 'D';
diff --git a/test/unit/src/utils/telemetry/gear.spec.js b/test/unit/src/utils/telemetry/gear.spec.js
new file mode 100644
index 00000000..a0d86cb2
--- /dev/null
+++ b/test/unit/src/utils/telemetry/gear.spec.js
@@ -0,0 +1,34 @@
+import { $gearInfo } from '@/utils/telemetry/_grear.utils';
+
+describe('Telemetry gear utils', () => {
+ const generateTransmissionData = (gear) => {
+ return { gear: { displayed: gear } };
+ };
+
+ describe('$gearInfo', () => {
+ test.each(['Toto', 'Mercedes'])(
+ 'The crawling gear should not exist for unsupported brand truck',
+ (brandName) => {
+ const gearDisplayed = 5;
+ const transmission = generateTransmissionData(gearDisplayed);
+ const result = $gearInfo(transmission, { name: brandName });
+
+ expect(result).toEqual({
+ gear: gearDisplayed,
+ crawlingGear: 0
+ });
+ }
+ );
+
+ test.each(['Volvo', 'Scania', 'Kenworth'])('tes', (brandName) => {
+ const gearDisplayed = 5;
+ const transmission = generateTransmissionData(gearDisplayed);
+ const result = $gearInfo(transmission, { name: brandName });
+
+ expect(result).toEqual({
+ gear: gearDisplayed,
+ crawlingGear: 2
+ });
+ });
+ });
+});
diff --git a/test/unit/test.helper.js b/test/unit/test.helper.js
index 777fe0d7..564bae23 100644
--- a/test/unit/test.helper.js
+++ b/test/unit/test.helper.js
@@ -3,11 +3,17 @@ export const changeTelemetryData = (obj, path, value) =>
export const deepChangeObjectValue = (obj, path, value) => {
let i;
+ const splitPath = path.split('.');
- path = path.split('.');
- for (i = 0; i < path.length - 1; i++) obj = obj[path[i]];
+ for (i = 0; i < splitPath.length - 1; i++) {
+ if (!Object.hasOwnProperty.call(obj, splitPath[i]))
+ throw new Error(
+ `The path "${path}" was not found on the original object`
+ );
+ obj = obj[splitPath[i]];
+ }
- obj[path[i]] = value;
+ obj[splitPath[i]] = value;
return obj;
};