imrishabh18/rp2040-motor-controller

An RP2040-based NEMA17 stepper-motor controller with USB-C programming and PD motor-power negotiation, DRV8825 dual H-bridge drive, current/temperature telemetry, protected power filtering, status RGB LED, buzzer alarm, and optional magnetic encoder.

Version
1.0.41
License
unset
Stars
3

tests/common-ground.test.tsx

import { expect, test } from "bun:test";
import { Circuit } from "tscircuit";
import Rp2040MotorController from "../index.circuit";
import { assertCommonGround } from "./helpers/assertCommonGround";

test("all grounds and mounting rings share connectivity; a missing ground connection is detected", async () => {
  const circuit = new Circuit({ platform: { pcbDisabled: true } });
  circuit.add(<Rp2040MotorController routingDisabled />);
  await circuit.renderUntilSettled();
  const json = circuit.getCircuitJson();
  expect(assertCommonGround(json).checkedGroundPorts).toBe(40);
  expect(json.filter((e) => (e.type === "schematic_net_label" || e.type === "schematic_text") &&
    e.text === "GND" && e.display_superscript)).toEqual([]);

  // Removing a real ground connection must fail despite matching GND names.
  const withoutTestPointGround = json.filter(e => !(e.type === "source_trace" && e.name === "TP_G"));
  expect(() => assertCommonGround(withoutTestPointGround)).toThrow();

}, 60_000);