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/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(29);
  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);