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.14
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 ground domains share electrical connectivity, and the missing join 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(18);
  expect(json.filter((e) => (e.type === "schematic_net_label" || e.type === "schematic_text") &&
    e.text === "GND" && e.display_superscript)).toEqual([]);

  // Recreate the original omission. Same-name labels and stale connectivity
  // keys must not make the disconnected source network appear connected.
  const withoutJoin = json.filter((e) => !(e.type === "source_trace" && e.name === "BOARD_GND_JOIN"));
  expect(() => assertCommonGround(withoutJoin)).toThrow("Disconnected GND networks");
}, 60_000);