imrishabh18/rp2040-motor-controller

The circuit implements a powered USB interface with a W25Q16 flash memory chip, a RP2040 microcontroller, and AO3400A MOSFETs for switch control, enabling USB communication, memory storage, and device power management.

Version
1.0.19
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);
});