bedSlinger.test.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { describe, it, expect } from 'vitest';
  2. import { isBedSlinger } from '../../utils/bedSlinger';
  3. describe('isBedSlinger', () => {
  4. it.each([
  5. 'A1',
  6. 'A1 Mini',
  7. 'A1 mini',
  8. 'A1MINI',
  9. 'A1-MINI',
  10. 'a1 mini',
  11. 'A1M',
  12. 'A2L',
  13. 'a2l',
  14. 'N1',
  15. 'N2S',
  16. 'N9',
  17. 'A04',
  18. 'A11',
  19. 'A12',
  20. ])('classifies %s as a bed-slinger', model => {
  21. expect(isBedSlinger(model)).toBe(true);
  22. });
  23. it.each([
  24. 'X1',
  25. 'X1C',
  26. 'X1E',
  27. 'X2D',
  28. 'P1P',
  29. 'P1S',
  30. 'P2S',
  31. 'H2D',
  32. 'H2D Pro',
  33. 'H2C',
  34. 'H2S',
  35. 'C11',
  36. 'C12',
  37. 'C13',
  38. 'N6',
  39. 'N7',
  40. 'O1D',
  41. 'O1E',
  42. 'O2D',
  43. 'O1C',
  44. 'O1C2',
  45. 'O1S',
  46. ])('classifies %s as bed-on-Z', model => {
  47. expect(isBedSlinger(model)).toBe(false);
  48. });
  49. it('treats an unknown or missing model as bed-on-Z', () => {
  50. // Bed-on-Z is what almost the whole fleet is, so it is the right default
  51. // for a name we do not recognise. It is not a free choice though: nothing
  52. // clamps a jog (#2579), so a misclassified bed-slinger sends its toolhead
  53. // at the plate on the first click of "up". Unknown A-series names are the
  54. // ones to watch when a new machine ships.
  55. expect(isBedSlinger(null)).toBe(false);
  56. expect(isBedSlinger(undefined)).toBe(false);
  57. expect(isBedSlinger('')).toBe(false);
  58. expect(isBedSlinger('Voron 2.4')).toBe(false);
  59. });
  60. it('does not sweep in other A-series names by prefix', () => {
  61. // The list is explicit on purpose — a prefix match would claim every
  62. // future "A<something>" before anyone has checked which way its Z goes.
  63. expect(isBedSlinger('A3')).toBe(false);
  64. expect(isBedSlinger('A1 Pro')).toBe(false);
  65. });
  66. });