Claude API

This commit is contained in:
chk
2026-06-08 19:04:31 +02:00
parent 10d306b7d4
commit c777f871cd
12 changed files with 529 additions and 28 deletions

View File

@@ -0,0 +1,25 @@
const GCode = require('../robot/GCode');
// Bug 6: containsMCode previously used indexOf('M1') == 0, which also matched
// M10, M11, M114, ... It must only match the standalone M1 motor command.
describe('GCode.containsMCode', () => {
test('matches the exact M1 command', () => {
expect(GCode.containsMCode('M1')).toBe(true);
});
test('matches M1 with parameters', () => {
expect(GCode.containsMCode('M1 X10 Y20 Z30')).toBe(true);
});
test('does NOT match higher M-codes that start with M1', () => {
expect(GCode.containsMCode('M10')).toBe(false);
expect(GCode.containsMCode('M11 X1')).toBe(false);
expect(GCode.containsMCode('M12')).toBe(false);
expect(GCode.containsMCode('M114')).toBe(false);
});
test('does NOT match unrelated commands or empty input', () => {
expect(GCode.containsMCode('G1 X1')).toBe(false);
expect(GCode.containsMCode('')).toBe(false);
});
});