krishnax12/watchy-eink-smartwatch

Unfinished prototype (not production-ready): 4 native DRC errors, 2 display-flex intersections, and missing antenna radiator copper remain

Version
1.2.7
License
MIT
Stars
1

scripts/component-ratings.test.ts

import { expect, test } from "bun:test";
import type { AnyCircuitElement } from "circuit-json";

test("e-paper capacitor quantities and ratings survive compilation", async () => {
	const circuit: AnyCircuitElement[] = await Bun.file(
		"dist/index/circuit.json",
	).json();
	const ratedCapacitors = [
		"C20",
		"C21",
		"C22",
		"C23",
		"C24",
		"C25",
		"C26",
		"C27",
		"C28",
		"C29",
	];
	for (const name of ratedCapacitors) {
		const capacitor = circuit.find(
			(element) => element.type === "source_component" && element.name === name,
		);
		if (
			!capacitor ||
			capacitor.type !== "source_component" ||
			capacitor.ftype !== "simple_capacitor"
		)
			throw new Error(`Missing capacitor ${name}`);
		const expectedCapacitance =
			name === "C20" || name === "C21" ? 4.7e-6 : 1e-6;
		expect(capacitor.capacitance, name).toBeCloseTo(expectedCapacitance, 12);
		expect(capacitor.max_voltage_rating, name).toBe(50);
		expect(capacitor.display_capacitance, name).toContain("/50V");
	}
});