var TenetSender = require('../robot/TelnetSenderGRBL.js') describe("TelnetSenderGRBL.execCommand - caseBackward", () => { test("reproduces the issue with yMotor and zMotor values", () => { // Create instance with default axis mappings (xAxisGrbl = "x", yAxisGrbl = "y", zAxisGrbl = "z") const sender = new TenetSender(urlGRBL = "test.test", maxSpeedF = 100, xAxisGrbl = "x", yAxisGrbl = "y", zAxisGrbl = "z"); // Mock tSocket.write sender.tSocket = { written: "", write: function(txt) { this.written = txt; // store what was written } }; // Provide the motion data from the log const mOld = { x: 0, y: 0, z: 0, a: 0, b: 0, c: 0, e: 0 }; // not used in your code const mNew = { x: 0.000, y: 0.203, z: -0.192, a: 0.000, b: 2.949, c: 1.571, e: -4.520 }; mNew.xMotorChanged = true; mNew.yMotorChanged = true; mNew.zMotorChanged = true; mNew.aMotorChanged = true; mNew.bMotorChanged = true; mNew.cMotorChanged = true; mNew.eMotorChanged = true; sender.execCommand("G1", mOld, mNew); // Expected output: since y and z have changed, both should be included // y: 0.203 * 180 / PI ≈ 11.64 // z: (-0.192 * 180 / PI) - (0.203 * 180 / PI) ≈ -10.99 - 11.64 ≈ -22.63 console.log("Actual output:", sender.tSocket.written); expect(sender.tSocket.written).toBe("G1 x0.00 y11.63 z-22.63 f100.00\r\n"); }); });