G92 ohne Senden
This commit is contained in:
53
test/Sender.Telnet.test.js
Executable file
53
test/Sender.Telnet.test.js
Executable file
@@ -0,0 +1,53 @@
|
||||
var TenetSender = require('../robot/TelnetSenderGRBL.js')
|
||||
|
||||
|
||||
describe("TelnetSenderGRBL.execCommand", () => {
|
||||
|
||||
test("writes correct G-code to mocked tSocket", () => {
|
||||
|
||||
// Create instance (will try real connection, but we override tSocket immediately)
|
||||
const sender = new TenetSender(urlGRBL = "test.test", maxSpeedF = 2300, xAxisGrbl = "x", yAxisGrbl = "y", zAxisGrbl = "z");
|
||||
|
||||
// Mock tSocket.write
|
||||
sender.tSocket = {
|
||||
written: "",
|
||||
write: function(txt) {
|
||||
this.written = txt; // store what was written
|
||||
}
|
||||
};
|
||||
|
||||
// Provide some sample motion data
|
||||
const mOld = { x: 0, y: 0, z: 0, a:0, b:0, c:0, e:0 }; // not used in your code
|
||||
const mNew = { x: 12.34, y: Math.PI/2, z: 0, a:0, b:0, c:0, e:0 };
|
||||
|
||||
sender.execCommand("G1", mOld, mNew);
|
||||
|
||||
// ✅ verify output
|
||||
expect(sender.tSocket.written).toBe("G1 x12.34 y90.00 z-90.00 f2300.00\r\n");
|
||||
});
|
||||
|
||||
|
||||
test("writes correct G-code G92 to mocked tSocket", () => {
|
||||
|
||||
// Create instance (will try real connection, but we override tSocket immediately)
|
||||
const sender = new TenetSender(urlGRBL = "test.test", maxSpeedF = 2300, xAxisGrbl = "x", yAxisGrbl = "y", zAxisGrbl = "z");
|
||||
|
||||
// Mock tSocket.write
|
||||
sender.tSocket = {
|
||||
written: "",
|
||||
write: function(txt) {
|
||||
this.written = txt; // store what was written
|
||||
}
|
||||
};
|
||||
|
||||
// Provide some sample motion data
|
||||
const mOld = { x: 0, y: 0, z: 0, a:0, b:0, c:0, e:0 }; // not used in your code
|
||||
const mNew = { x: 12.34, y: 1.0, z: 2.0, a:0, b:0, c:0, e:0 };
|
||||
|
||||
sender.execCommand("G92", mOld, mNew);
|
||||
|
||||
// ✅ verify output
|
||||
expect(sender.tSocket.written).toBe("G92 x12.34 y57.30 z57.30 f2300.00\r\n");
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user