imrishabh18/rp2040-motor-controller

An RP2040-based NEMA17 stepper-motor controller with USB-C programming and PD motor-power negotiation, DRV8825 dual H-bridge drive, current/temperature telemetry, protected power filtering, status RGB LED, buzzer alarm, and optional magnetic encoder.

Version
1.0.42
License
unset
Stars
3

tests/automatic-schematic-layout.test.ts

import { expect, test } from 'bun:test';
import { Children, isValidElement } from 'react';
import Board from '../index.circuit';

test('passives have no schematic coordinates and belong to automatic section groups', () => {
  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' && 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' && /^[RCLYDF]_?\d|^[RCLYDF]_/.test(props.name ?? ''))) {
      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(60);
});