astra/nema17-stepper-motor-controller-spring-clamp-rp2040
A 4-layer RP2040 controller board that negotiates USB‑C PD motor power and drives a NEMA17 stepper via a DRV8825, with current sensing, thermal shutdown, RGB status LED, buzzer alarm, optional AS5600 encoder, protection/filtering, and test points.
- Version
- 1.4.0
- 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);
});
test("saved routing accepts deduplicated connectivity IDs from newer core", async () => {
const input = structuredClone(plan.expectedInput);
for (const obstacle of input.obstacles) {
obstacle.connectedTo = [...new Set(obstacle.connectedTo)].reverse();
}
const router = await savedRouting(input);
let routes: unknown;
router.on("complete", event => { routes = event.traces; });
router.start();
expect(routes).toEqual(plan.traces);
});
test("saved routing still rejects changed obstacle connectivity", async () => {
for (const change of ["add", "remove"]) {
const input = structuredClone(plan.expectedInput);
const ids = [...new Set(input.obstacles[0].connectedTo)];
if (change === "add") ids.push("pcb_port_unexpected");
else ids.pop();
input.obstacles[0].connectedTo = ids;
await expect(savedRouting(input)).rejects.toThrow("Regenerate and validate");
}
});