* CEC-1050 Manifest changes * Fix delete bug * Add approve update button * Code smell * Remove update approval
79 lines
1.6 KiB
JavaScript
79 lines
1.6 KiB
JavaScript
import React from "react";
|
|
|
|
let busy = false;
|
|
let vehicles = [];
|
|
let models = ["Ocean", "PEAR"];
|
|
let years = [2023, 2024];
|
|
let totalVehicles = 0;
|
|
let error = null;
|
|
|
|
export const VehicleProvider = ({ children }) => {
|
|
return <div data-testid="mocked-vehicleprovider">{children}</div>;
|
|
};
|
|
|
|
export const useVehicleContext = () => ({
|
|
busy,
|
|
models,
|
|
totalVehicles,
|
|
vehicles,
|
|
years,
|
|
addVehicle: jest.fn(),
|
|
getConnections: jest.fn((vins, token) => {
|
|
const result = {};
|
|
|
|
vins.forEach((vin) => {
|
|
result[vin] = true;
|
|
});
|
|
|
|
return result;
|
|
}),
|
|
getECUs: jest.fn(() => {
|
|
return {
|
|
data: [
|
|
{
|
|
config: "CONFIG",
|
|
created: "2021-07-14T20:09:40.98187Z",
|
|
ecu: "ECUA",
|
|
hw_version: "HWVERSION",
|
|
sw_version: "SWVERSION",
|
|
updated: "2021-07-14T20:09:40.98187Z",
|
|
},
|
|
{
|
|
config: "CONFIG",
|
|
created: "2021-07-14T20:09:40.98187Z",
|
|
hw_version: "HWVERSION",
|
|
sw_version: "SWVERSION",
|
|
updated: "2021-07-14T20:09:40.98187Z",
|
|
},
|
|
],
|
|
total: 2,
|
|
};
|
|
}),
|
|
getLocations: jest
|
|
.fn()
|
|
.mockResolvedValue([
|
|
{ altitude: 5, longitude: 10, latitude: 15, vin: "TESTVIN123" },
|
|
]),
|
|
getModels: jest.fn(() => {
|
|
models = ["Ocean", "PEAR"];
|
|
}),
|
|
getState: jest.fn(),
|
|
getYears: jest.fn(() => {
|
|
years = [2023, 2024];
|
|
}),
|
|
getVehicles: jest.fn(() => vehicles),
|
|
sendCommand: jest.fn((vins, command, parameters, token) => ({
|
|
vins,
|
|
command,
|
|
parameters,
|
|
})),
|
|
});
|
|
|
|
export const setBusy = (val) => {
|
|
busy = val;
|
|
};
|
|
|
|
export const setVehicles = (val) => {
|
|
vehicles = val;
|
|
};
|