Merge branch 'release/0.9.0'
This commit is contained in:
@@ -80,12 +80,28 @@ export const ManifestsProvider = ({ children }) => {
|
||||
return result;
|
||||
};
|
||||
|
||||
const migrateManifest = async (package_id, token) => {
|
||||
let result;
|
||||
|
||||
try{
|
||||
setBusy(true)
|
||||
result = await api.migrateManifest(package_id, token)
|
||||
if(result.error)
|
||||
throw new Error(`failed to migrate manifest. ${result.message}`);
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
return result
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<ManifestsContext.Provider
|
||||
value={{
|
||||
busy,
|
||||
manifests,
|
||||
totalManifests,
|
||||
migrateManifest,
|
||||
updateManifest,
|
||||
getManifest,
|
||||
getManifests,
|
||||
|
||||
@@ -88,7 +88,19 @@ export const VehicleProvider = ({ children }) => {
|
||||
setBusy(true);
|
||||
const result = await api.getLocations(token);
|
||||
if (result.error)
|
||||
throw new Error(`Get locations error. ${result.message}`);
|
||||
throw new Error(`Get locations vehicle paths error. ${result.message}`);
|
||||
return result;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const getLocationsVehiclePaths = async (token, vinsParam) => {
|
||||
try {
|
||||
setBusy(true);
|
||||
const result = await api.getLocationsVehiclePaths(token, vinsParam);
|
||||
if (result.error)
|
||||
throw new Error(`Get locations vehicle paths error. ${result.message}`);
|
||||
return result;
|
||||
} finally {
|
||||
setBusy(false);
|
||||
@@ -263,6 +275,7 @@ export const VehicleProvider = ({ children }) => {
|
||||
getCANSignals,
|
||||
getECUs,
|
||||
getLocations,
|
||||
getLocationsVehiclePaths,
|
||||
getModels,
|
||||
getState,
|
||||
getYears,
|
||||
|
||||
@@ -98,15 +98,14 @@ export const useVehicleContext = () => ({
|
||||
vehicles,
|
||||
years,
|
||||
addVehicle: jest.fn(),
|
||||
getConnections: jest.fn((vins, _token) => {
|
||||
const result = {};
|
||||
|
||||
vins.forEach((vin) => {
|
||||
result[vin] = true;
|
||||
});
|
||||
|
||||
return result;
|
||||
}),
|
||||
getConnections: jest
|
||||
.fn().mockImplementation((vins, _token) => {
|
||||
const result = {};
|
||||
vins.forEach((vin) => {
|
||||
result[vin] = true;
|
||||
});
|
||||
return Promise.resolve(result);
|
||||
}),
|
||||
getECUs: jest.fn(() => {
|
||||
return {
|
||||
data: [
|
||||
@@ -134,6 +133,13 @@ export const useVehicleContext = () => ({
|
||||
.mockResolvedValue([
|
||||
{ altitude: 5, longitude: 10, latitude: 15, vin: "TESTVIN123" },
|
||||
]),
|
||||
getLocationsVehiclePaths: jest
|
||||
.fn()
|
||||
.mockResolvedValue({
|
||||
// tests only pass without mocking the data here
|
||||
// '3FAFP13P31R199430': [[16.891136999999986, 26.832352999999955], [56.891136999999986, 66.832352999999955], [26.891136999999986, 36.832352999999955]],
|
||||
// '3FAFP13P71R199060': [[36.891136999999986, 46.832352999999955], [76.891136999999986, 16.832352999999955]],
|
||||
}),
|
||||
getModels: jest.fn(() => {
|
||||
models = ["Ocean", "PEAR"];
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user