G92 ohne Senden2
This commit is contained in:
@@ -27,6 +27,29 @@ describe("TelnetSenderGRBL.execCommand", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test("writes correct G-code to mocked tSocket Ellbow", () => {
|
||||||
|
|
||||||
|
// Create instance (will try real connection, but we override tSocket immediately)
|
||||||
|
const sender = new TenetSender(urlGRBL = "test.test", maxSpeedF = 2300, xAxisGrbl = "a", yAxisGrbl = null, zAxisGrbl = null );
|
||||||
|
|
||||||
|
// 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:Math.PI, b:0, c:0, e:0 }; // not used in your code
|
||||||
|
const mNew = { x: 12.34, y: Math.PI/2, z: 0, a:Math.PI/8, b:0, c:0, e:0 };
|
||||||
|
|
||||||
|
sender.execCommand("G1", mOld, mNew);
|
||||||
|
|
||||||
|
// ✅ verify output
|
||||||
|
expect(sender.tSocket.written).toBe("G1 x22.50 f2300.00\r\n");
|
||||||
|
});
|
||||||
|
|
||||||
test("writes correct G-code G92 to mocked tSocket", () => {
|
test("writes correct G-code G92 to mocked tSocket", () => {
|
||||||
|
|
||||||
// Create instance (will try real connection, but we override tSocket immediately)
|
// Create instance (will try real connection, but we override tSocket immediately)
|
||||||
|
|||||||
@@ -27,6 +27,29 @@ describe("WS-SenderGRBL.execCommand", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
test("writes correct G-code to mocked tSocket Ellbow", () => {
|
||||||
|
|
||||||
|
// Create instance (will try real connection, but we override tSocket immediately)
|
||||||
|
const sender = new Sender(urlGRBL = "test.test", maxSpeedF = 2300, xAxisGrbl = "a", yAxisGrbl = null, zAxisGrbl = null );
|
||||||
|
|
||||||
|
// 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:Math.PI, b:0, c:0, e:0 }; // not used in your code
|
||||||
|
const mNew = { x: 12.34, y: Math.PI/2, z: 0, a:Math.PI/8, b:0, c:0, e:0 };
|
||||||
|
|
||||||
|
sender.execCommand("G1", mOld, mNew);
|
||||||
|
|
||||||
|
// ✅ verify output
|
||||||
|
expect(sender.tSocket.written).toBe("G1 x22.50 f2300.00\r\n");
|
||||||
|
});
|
||||||
|
|
||||||
test("writes correct G-code G92 to mocked WS tSocket", () => {
|
test("writes correct G-code G92 to mocked WS tSocket", () => {
|
||||||
|
|
||||||
// Create instance (will try real connection, but we override tSocket immediately)
|
// Create instance (will try real connection, but we override tSocket immediately)
|
||||||
|
|||||||
Reference in New Issue
Block a user