Test mit Jest
Das AI generierte mocking ignorieren, und sauber, wie davor.
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
|
||||
const { calculate, optimizeRobot } = require('./calculateAngles.js');
|
||||
module.exports = { calculate, optimizeRobot };
|
||||
@@ -93,7 +93,9 @@ function optimizeRobot(listFoundMarkers, jsonRobot) {
|
||||
...entry,
|
||||
n: 0,
|
||||
average: null,
|
||||
deviation: null
|
||||
deviation: null,
|
||||
result: "X",
|
||||
status: "ok"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -104,12 +106,17 @@ function optimizeRobot(listFoundMarkers, jsonRobot) {
|
||||
...entry,
|
||||
n,
|
||||
average,
|
||||
deviation
|
||||
deviation,
|
||||
result: "X",
|
||||
status: "ok"
|
||||
};
|
||||
});
|
||||
withStats.status = "ok";
|
||||
withStats.result = "X";
|
||||
|
||||
return withStats;
|
||||
}
|
||||
|
||||
function calculateRotationAngle(listIdAndX, jsonRobot, jointName, method = "tan") {
|
||||
// Achse finden
|
||||
const jointInfo = jsonRobot.Joints[jointName];
|
||||
@@ -212,4 +219,16 @@ async function calculate(foundMarkers, jsonRobot) {
|
||||
}
|
||||
|
||||
|
||||
module.exports = { calculate, optimizeRobot };
|
||||
// export { calculate, optimizeRobot };
|
||||
|
||||
if (typeof window !== "undefined") {
|
||||
window.calculate = calculate;
|
||||
window.optimizeRobot = optimizeRobot;
|
||||
}
|
||||
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = {
|
||||
calculate,
|
||||
optimizeRobot
|
||||
};
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
|
||||
import cjs from './calculateAngles.js';
|
||||
|
||||
export const calculate = cjs.calculate;
|
||||
export const optimizeRobot = cjs.optimizeRobot;
|
||||
|
||||
export async function fetchAndCalculate() {
|
||||
const res = await fetch("/api/latest-snapshot");
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
window.calculateAngles = window.calculateAngles || {};
|
||||
window.calculateAngles.calculate = calculate;
|
||||
window.calculateAngles.fetchAndCalculate = fetchAndCalculate;
|
||||
|
||||
// automatisch starten
|
||||
fetchAndCalculate();
|
||||
}
|
||||
|
||||
export { calculate, fetchAndCalculate };
|
||||
Reference in New Issue
Block a user