imrishabh18/rp2040-motor-controller

This circuit module provides a microcontroller-based NEMA17 stepper motor driver with integrated USB-C Power Delivery, temperature sensing, and safety interlocks.

Version
1.0.16
License
unset
Stars
0

tests/saved-routing.test.ts

import { expect, test } from "bun:test";
import plan from "../routing/route-plan.json";
import { savedRouting } from "../routing/saved-routing";

test("saved routing refuses moved terminals, changed connections and changed clearances", async () => {
  for (const mutate of [
    (input: any) => { input.connections[0].pointsToConnect[0].x += 0.1; },
    (input: any) => { input.connections[0].pointsToConnect.pop(); },
    (input: any) => { input.minTraceToPadEdgeClearance += 0.05; },
  ]) {
    const input = structuredClone(plan.expectedInput);
    mutate(input);
    await expect(savedRouting(input)).rejects.toThrow("Regenerate and validate");
  }
});

test("saved routing supplies a fresh copy of the complete route geometry", async () => {
  const router = await savedRouting(structuredClone(plan.expectedInput));
  let routes: any[] = [];
  router.on("complete", event => { routes = event.traces; });
  router.start();
  expect(routes.length).toBe(plan.traces.length);
  expect(routes).toEqual(plan.traces);
  routes[0].route[0].x += 1;
  expect(routes[0].route[0].x).not.toBe(plan.traces[0].route[0].x);
});