diff --git a/tests/capacitive-touch-slider.test.tsx b/tests/capacitive-touch-slider.test.tsx new file mode 100644 index 000000000..83ceaf521 --- /dev/null +++ b/tests/capacitive-touch-slider.test.tsx @@ -0,0 +1,106 @@ +import { test, expect } from "bun:test" +import { Circuit } from "../lib/Circuit" + +// Capacitive Touch Slider Test +// This test demonstrates polygon smtpads with solder mask for capacitive touch + +test("capacitive touch slider with polygon smtpads and solder mask", () => { + const circuit = new Circuit() + + circuit.add( + + {/* Capacitive touch slider with 5 segments */} + + {/* Segment 1 */} + + {/* Segment 2 */} + + {/* Segment 3 */} + + {/* Segment 4 */} + + {/* Segment 5 */} + + + + ) + + circuit.render() + + // Get PCB elements + const pcbElements = circuit.getCircuitJson() + + // Check for smtpad elements + const smtpads = pcbElements.filter((el: any) => el.type === "pcb_smtpad") + expect(smtpads.length).toBe(5) + + // Check that all smtpads have coveredWithSolderMask + for (const smtpad of smtpads) { + expect(smtpad.shape).toBe("polygon") + expect(smtpad.is_covered_with_solder_mask).toBe(true) + expect(smtpad.soldermask_margin).toBe(0.1) + } + + // Generate snapshot for visual verification + expect(circuit.getCircuitJson()).toMatchSnapshot("capacitive-touch-slider") +})