imrishabh18/pedometer

This code defines and assembles a simple radio receiver hardware circuit using specific imported capacitors, inductors, RF connectors, and oscillator components with precise footprints and schematic attributes.

Version
1.1.3
License
unset
Stars
0

tests/no-via-in-pad.test.ts

import { test, expect } from "bun:test";
import { prepareBgaRouting } from "../bga-autorouter";
import { auditBgaVias } from "../scripts/check-no-via-in-pad";

test("via-in-pad disabled leaves an enclosed BGA terminal on its pad layer", () => {
  const obstacles = Array.from({length:9},(_,i)=>({type:"rect", componentId:"bga",
    center:{x:(i%3)*.4,y:Math.floor(i/3)*.4},width:.23,height:.23,layers:["top"],connectedTo:i===4?[`pad${i}`,"center"]:[`pad${i}`],
    circuitJsonMetadata:{pcb_smtpad_id:`pad${i}`}}));
  const input:any={layerCount:4,minTraceWidth:.1,minViaPadDiameter:.3,minViaHoleDiameter:.15,
    bounds:{minX:-3,maxX:3,minY:-3,maxY:3},obstacles,
    connections:[{name:"center",pointsToConnect:[{x:.4,y:.4,layer:"top"},{x:2,y:2,layer:"top"}]}]};
  for (const allowViaInPad of [false,undefined]) {
    const output=prepareBgaRouting({...input,allowViaInPad});
    expect(output.connections[0].pointsToConnect).toEqual(input.connections[0].pointsToConnect);
    expect(output.obstacles).toHaveLength(9);
  }
  // With explicit opt-in, FanoutSolver validates the interior terminal escape.
  const enabled=prepareBgaRouting({...input,allowViaInPad:true});
  expect(enabled.connections[0].pointsToConnect[0]).toMatchObject({layer:"bottom",terminalVia:{toLayer:"top"}});
});

test("physical via audit catches same-net and bottom-to-inner through drills", () => {
  const fixture:any[]=[
    {type:"source_component",source_component_id:"s",name:"TEST",manufacturer_part_number:"BQ25150YFPR"},
    {type:"pcb_component",pcb_component_id:"c",source_component_id:"s"},
    {type:"pcb_smtpad",pcb_component_id:"c",pcb_smtpad_id:"p",port_hints:["pin1"],layer:"top",shape:"circle",x:0,y:0,radius:.115,soldermask_margin:.05},
    {type:"pcb_via",pcb_via_id:"v",x:0,y:0,hole_diameter:.15,from_layer:"bottom",to_layer:"inner2",layers:["top","inner1","inner2","bottom"]},
  ];
  expect(auditBgaVias(fixture).viaInPadCount).toBe(1);
  fixture[3].x=.22; // drill clears copper but still intersects the mask opening
  expect(auditBgaVias(fixture).viaInPadCount).toBe(0);
  expect(auditBgaVias(fixture).viaInMaskOpeningCount).toBe(1);
  fixture[3].x=.5;
  expect(auditBgaVias(fixture).violations).toHaveLength(0);
});