imrishabh18/rp2040-motor-controller
Bottom-side PCB silkscreen artwork implementing mirrored tsCircuit logos as embedded SVG paths, with via-clearance-aware placement and no active electronics.
- Version
- 1.0.57
- License
- unset
- Stars
- 5
tests/automatic-schematic-layout.test.ts
import { expect, test } from 'bun:test';
import { Children, isValidElement } from 'react';
import Board from '../index.circuit';
test('components and layout groups have no schematic coordinates', () => {
let passiveCount = 0;
const passiveTypes = new Set(['resistor', 'capacitor', 'inductor', 'crystal', 'diode', 'led', 'fuse']);
function visit(node: any, sectionGroup?: any) {
if (!isValidElement<any>(node)) return;
const props = node.props;
if (node.type === 'group') {
expect(props.schX).toBeUndefined();
expect(props.schY).toBeUndefined();
}
if (node.type === 'group' && props.name?.startsWith('layout_')) {
sectionGroup = props;
expect(props.schAutoLayoutEnabled).toBe(true);
expect([props.pcbX, props.pcbY]).toEqual([0, 0]);
}
if (passiveTypes.has(node.type as string) || node.type === 'chip' || node.type === 'pushbutton' || node.type === 'mosfet') {
passiveCount++;
expect(props.schX).toBeUndefined();
expect(props.schY).toBeUndefined();
expect(props.schSectionName).toBeTruthy();
expect(sectionGroup?.name).toBe(`layout_${props.schSectionName}`);
}
Children.forEach(props.children, child => visit(child, sectionGroup));
}
visit(Board({routingDisabled:true}));
expect(passiveCount).toBeGreaterThan(100);
});
import { packMeasuredGroups } from '../schematic/packMeasuredGroups';
test('measured group packing uses the space below small groups without overlap', () => {
const groups = packMeasuredGroups([{width: 8, height: 14}, {width: 6, height: 4}, {width: 6, height: 3}], 16);
expect(Math.max(...groups.map(group => group.y + group.height))).toBe(14);
for (const [i, a] of groups.entries()) for (const b of groups.slice(i + 1))
expect(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y).toBe(true);
});