imrishabh18/rp2040-motor-controller
Bottom-side mirrored PCB silkscreen logos rendered as embedded SVG graphics, including via-clearance-aware placement and scaling.
- Version
- 1.0.47
- License
- unset
- Stars
- 5
tests/pd-bus-voltage-monitor.test.tsx
import { expect, test } from "bun:test";
import { Circuit } from "tscircuit";
import Board from "../index.circuit";
import { assertPdBusVoltageMonitor } from "./helpers/assertPdBusVoltageMonitor";
test("raw PD VBUS measurement is isolated from 3.3 V, DATA USB, and protected motor rail", async () => {
const circuit = new Circuit({ platform: { pcbDisabled: true } });
circuit.add(<Board routingDisabled />);
await circuit.renderUntilSettled();
const json = circuit.getCircuitJson();
expect(assertPdBusVoltageMonitor(json).status).toBe("pass");
const disconnected = structuredClone(json).filter(element =>
!(element.type === "source_trace" && element.name === "PD_MON_VBUS"));
expect(() => assertPdBusVoltageMonitor(disconnected)).toThrow();
const shorted = structuredClone(json);
const bus = shorted.find(element => element.type === "source_trace" && element.name === "PD_MON_VBUS");
const supply = shorted.find(element => element.type === "source_trace" && element.name === "PD_MON_VS");
if (bus?.type !== "source_trace" || supply?.type !== "source_trace") throw new Error("Missing test traces");
bus.connected_source_port_ids.push(supply.connected_source_port_ids[0]!);
expect(() => assertPdBusVoltageMonitor(shorted)).toThrow();
}, 60000);