shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

tests/bom-validation.test.ts

import {test,expect} from "bun:test"
import {parseCatalogValue,validateCatalogPart} from "../scripts/validate-bom.mjs"
import {parseJlcProduct} from "../scripts/audit-jlcpcb-stock.mjs"

test("stock and attributes can be separate server-rendered catalog records",()=>{
  const stream='1:'+JSON.stringify({componentCode:"C1",componentModelEn:"R49R9",componentSpecificationEn:"0402",
    overseasStockCount:100,canPresaleNumber:90,isBuyComponent:"1"})+'\n2:'+JSON.stringify({componentCode:"C1",attributes:"$3"})+
    '\n3:["$4"]\n4:'+JSON.stringify({attribute_name_en:"Resistance",attribute_value_name:"49.9Ω"})+'\n'
  const html=`<script>self.__next_f.push(${JSON.stringify([1,stream])})</script>`
  expect(parseJlcProduct(html,"C1").attributes).toEqual({Resistance:"49.9Ω"})
})

test("catalog units preserve milli, kilo, micro and nano",()=>{
  expect(parseCatalogValue("49.9Ω","Ω")).toBe(49.9)
  expect(parseCatalogValue("47kΩ","Ω")).toBe(47000)
  expect(parseCatalogValue("300mΩ","Ω")).toBe(.3)
  expect(parseCatalogValue("6.8nF","F")).toBeCloseTo(6.8e-9,15)
  expect(parseCatalogValue("22µF","F")).toBeCloseTo(22e-6,12)
  expect(parseCatalogValue("unavailable","F")).toBeNull()
})
test("a stocked 47k termination cannot pass as 49.9 ohms",()=>{
  expect(validateCatalogPart({resistance:49.9},{attributes:{Resistance:"47kΩ"}})).toHaveLength(1)
})
test("wrong capacitor value and insufficient rating both fail",()=>{
  expect(validateCatalogPart({ftype:"simple_capacitor",capacitance:6.8e-9,max_voltage_rating:50},
    {attributes:{Capacitance:"100nF","Voltage Rating":"25V"}})).toHaveLength(2)
})
test("missing catalog attributes fail closed",()=>{
  expect(validateCatalogPart({resistance:9100},{attributes:{}})).toHaveLength(1)
})
test("correct replacement capacitor passes declared electrical values",()=>{
  expect(validateCatalogPart({ftype:"simple_capacitor",capacitance:22e-6,max_voltage_rating:50},
    {attributes:{Capacitance:"22uF","Voltage Rating":"50V"}})).toEqual([])
})