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-power-good.test.tsx

import { expect, test } from 'bun:test';
import { Circuit } from 'tscircuit';
import Board from '../index.circuit';
import { assertPdPowerGood } from './helpers/assertPdPowerGood';

test('PG reads on GPIO7 without joining USB supply domains or bypassing the sleep interlock', async () => {
  const circuit = new Circuit({platform: {pcbDisabled: true}});
  circuit.add(<Board routingDisabled />);
  await circuit.renderUntilSettled();
  const json = circuit.getCircuitJson();
  expect(assertPdPowerGood(json).status).toBe('pass');
  for (const name of ['PD_PG_SENSE', 'PD_PG_SUPPLY_SENSE', 'PD_PG_FUNCTION', 'PD_GOOD']) {
    expect(() => assertPdPowerGood(json.filter((e: any) => !(e.type === 'source_trace' && e.name === name)))).toThrow();
  }
  const shorted = structuredClone(json) as any[];
  const pg = shorted.find(e => e.type === 'source_trace' && e.name === 'PD_PG_SENSE');
  const output = shorted.find(e => e.type === 'source_trace' && e.name === 'PD_GOOD');
  pg.connected_source_port_ids.push(output.connected_source_port_ids[1]);
  expect(() => assertPdPowerGood(shorted)).toThrow();
}, 60000);